mirror of
https://github.com/ppy/osu.git
synced 2025-01-16 00:03:22 +08:00
Merge branch 'master' into replay_mods
This commit is contained in:
commit
33f4f57ee3
62
osu.Game.Tests/Visual/TestCaseBadgeContainer.cs
Normal file
62
osu.Game.Tests/Visual/TestCaseBadgeContainer.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Overlays.Profile.Header;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestCaseBadgeContainer : OsuTestCase
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BadgeContainer) };
|
||||||
|
|
||||||
|
public TestCaseBadgeContainer()
|
||||||
|
{
|
||||||
|
BadgeContainer badgeContainer;
|
||||||
|
|
||||||
|
Child = badgeContainer = new BadgeContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("Show 1 badge", () => badgeContainer.ShowBadges(new[]
|
||||||
|
{
|
||||||
|
new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.Now,
|
||||||
|
Description = "Appreciates compasses",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/mg2018-1star.png",
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("Show 2 badges", () => badgeContainer.ShowBadges(new[]
|
||||||
|
{
|
||||||
|
new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.Now,
|
||||||
|
Description = "Contributed to osu!lazer testing",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.png",
|
||||||
|
},
|
||||||
|
new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.Now,
|
||||||
|
Description = "Appreciates compasses",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/mg2018-1star.png",
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddStep("Show many badges", () => badgeContainer.ShowBadges(Enumerable.Range(1, 20).Select(i => new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.Now,
|
||||||
|
Description = $"Contributed to osu!lazer testing {i} times",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
||||||
|
}).ToArray()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 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.Game.Overlays.Profile;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -11,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays.Profile.Header;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
|
@ -8,6 +8,7 @@ using NUnit.Framework;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Profile;
|
using osu.Game.Overlays.Profile;
|
||||||
|
using osu.Game.Overlays.Profile.Header;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -23,6 +24,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
typeof(UserProfileOverlay),
|
typeof(UserProfileOverlay),
|
||||||
typeof(RankGraph),
|
typeof(RankGraph),
|
||||||
typeof(LineGraph),
|
typeof(LineGraph),
|
||||||
|
typeof(BadgeContainer)
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestCaseUserProfile()
|
public TestCaseUserProfile()
|
||||||
@ -53,6 +55,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
Mode = @"osu",
|
Mode = @"osu",
|
||||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||||
|
},
|
||||||
|
Badges = new[]
|
||||||
|
{
|
||||||
|
new Badge
|
||||||
|
{
|
||||||
|
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
||||||
|
Description = "Outstanding help by being a voluntary test subject.",
|
||||||
|
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, false));
|
}, false));
|
||||||
|
|
||||||
|
195
osu.Game/Overlays/Profile/Header/BadgeContainer.cs
Normal file
195
osu.Game/Overlays/Profile/Header/BadgeContainer.cs
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
|
{
|
||||||
|
public class BadgeContainer : Container
|
||||||
|
{
|
||||||
|
private static readonly Vector2 badge_size = new Vector2(86, 40);
|
||||||
|
private static readonly MarginPadding outer_padding = new MarginPadding(3);
|
||||||
|
|
||||||
|
private OsuSpriteText badgeCountText;
|
||||||
|
private FillFlowContainer badgeFlowContainer;
|
||||||
|
private FillFlowContainer outerBadgeContainer;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 4,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colours.Gray3
|
||||||
|
},
|
||||||
|
outerBadgeContainer = new OuterBadgeContainer(onOuterHover, onOuterHoverLost)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Padding = outer_padding,
|
||||||
|
Width = DrawableBadge.DRAWABLE_BADGE_SIZE.X + outer_padding.TotalHorizontal,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
badgeCountText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
TextSize = 12,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Font = "Exo2.0-Regular"
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Child = badgeFlowContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Scheduler.AddDelayed(rotateBadges, 3000, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rotateBadges()
|
||||||
|
{
|
||||||
|
if (outerBadgeContainer.IsHovered) return;
|
||||||
|
|
||||||
|
visibleBadge = (visibleBadge + 1) % badgeCount;
|
||||||
|
|
||||||
|
badgeFlowContainer.MoveToX(-DrawableBadge.DRAWABLE_BADGE_SIZE.X * visibleBadge, 500, Easing.InOutQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int visibleBadge;
|
||||||
|
private int badgeCount;
|
||||||
|
|
||||||
|
public void ShowBadges(Badge[] badges)
|
||||||
|
{
|
||||||
|
switch (badges.Length)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Hide();
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
badgeCountText.Hide();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
badgeCountText.Show();
|
||||||
|
badgeCountText.Text = $"{badges.Length} badges";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Show();
|
||||||
|
badgeCount = badges.Length;
|
||||||
|
visibleBadge = 0;
|
||||||
|
|
||||||
|
badgeFlowContainer.Clear();
|
||||||
|
foreach (var badge in badges)
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new DrawableBadge(badge)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
}, badgeFlowContainer.Add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOuterHover()
|
||||||
|
{
|
||||||
|
badgeFlowContainer.ClearTransforms();
|
||||||
|
badgeFlowContainer.X = 0;
|
||||||
|
badgeFlowContainer.Direction = FillDirection.Full;
|
||||||
|
outerBadgeContainer.AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
badgeFlowContainer.MaximumSize = new Vector2(ChildSize.X, float.MaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOuterHoverLost()
|
||||||
|
{
|
||||||
|
badgeFlowContainer.X = -DrawableBadge.DRAWABLE_BADGE_SIZE.X * visibleBadge;
|
||||||
|
badgeFlowContainer.Direction = FillDirection.Horizontal;
|
||||||
|
outerBadgeContainer.AutoSizeAxes = Axes.Y;
|
||||||
|
outerBadgeContainer.Width = DrawableBadge.DRAWABLE_BADGE_SIZE.X + outer_padding.TotalHorizontal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OuterBadgeContainer : FillFlowContainer
|
||||||
|
{
|
||||||
|
private readonly Action hoverAction;
|
||||||
|
private readonly Action hoverLostAction;
|
||||||
|
|
||||||
|
public OuterBadgeContainer(Action hoverAction, Action hoverLostAction)
|
||||||
|
{
|
||||||
|
this.hoverAction = hoverAction;
|
||||||
|
this.hoverLostAction = hoverLostAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
hoverAction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state) => hoverLostAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DrawableBadge : Container, IHasTooltip
|
||||||
|
{
|
||||||
|
public static readonly Vector2 DRAWABLE_BADGE_SIZE = badge_size + outer_padding.Total;
|
||||||
|
|
||||||
|
private readonly Badge badge;
|
||||||
|
|
||||||
|
public DrawableBadge(Badge badge)
|
||||||
|
{
|
||||||
|
this.badge = badge;
|
||||||
|
Padding = outer_padding;
|
||||||
|
Size = DRAWABLE_BADGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
Child = new Sprite
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Texture = textures.Get(badge.ImageUrl),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Child.FadeInFromZero(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TooltipText => badge.Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,10 @@
|
|||||||
// 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 System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -14,10 +15,9 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using System.Collections.Generic;
|
using OpenTK;
|
||||||
using osu.Framework.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class RankGraph : Container
|
public class RankGraph : Container
|
||||||
{
|
{
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 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 OpenTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -9,8 +8,9 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile
|
namespace osu.Game.Overlays.Profile.Header
|
||||||
{
|
{
|
||||||
public class SupporterIcon : CircularContainer, IHasTooltip
|
public class SupporterIcon : CircularContainer, IHasTooltip
|
||||||
{
|
{
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Overlays.Profile.Header;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile
|
namespace osu.Game.Overlays.Profile
|
||||||
@ -35,6 +36,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
||||||
private readonly Box colourBar;
|
private readonly Box colourBar;
|
||||||
private readonly DrawableFlag countryFlag;
|
private readonly DrawableFlag countryFlag;
|
||||||
|
private readonly BadgeContainer badgeContainer;
|
||||||
|
|
||||||
private const float cover_height = 350;
|
private const float cover_height = 350;
|
||||||
private const float info_height = 150;
|
private const float info_height = 150;
|
||||||
@ -42,6 +44,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
private const float avatar_size = 110;
|
private const float avatar_size = 110;
|
||||||
private const float level_position = 30;
|
private const float level_position = 30;
|
||||||
private const float level_height = 60;
|
private const float level_height = 60;
|
||||||
|
private const float stats_width = 280;
|
||||||
|
|
||||||
public ProfileHeader(User user)
|
public ProfileHeader(User user)
|
||||||
{
|
{
|
||||||
@ -66,9 +69,9 @@ namespace osu.Game.Overlays.Profile
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
X = UserProfileOverlay.CONTENT_X_MARGIN,
|
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN, Bottom = 20, Right = stats_width + UserProfileOverlay.CONTENT_X_MARGIN },
|
||||||
Y = -20,
|
AutoSizeAxes = Axes.Y,
|
||||||
AutoSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new UpdateableAvatar
|
new UpdateableAvatar
|
||||||
@ -116,7 +119,15 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Height = 20
|
Height = 20
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
badgeContainer = new BadgeContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Margin = new MarginPadding { Bottom = 5 },
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
colourBar = new Box
|
colourBar = new Box
|
||||||
@ -156,7 +167,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
{
|
{
|
||||||
X = -UserProfileOverlay.CONTENT_X_MARGIN,
|
X = -UserProfileOverlay.CONTENT_X_MARGIN,
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 280,
|
Width = stats_width,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -417,6 +428,8 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
rankGraph.User.Value = user;
|
rankGraph.User.Value = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badgeContainer.ShowBadges(user.Badges);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
|
private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
|
||||||
|
@ -39,8 +39,9 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
private readonly LoadingAnimation loading;
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
private IEnumerable<Score> scores;
|
private ScheduledDelegate showScoresDelegate;
|
||||||
|
|
||||||
|
private IEnumerable<Score> scores;
|
||||||
public IEnumerable<Score> Scores
|
public IEnumerable<Score> Scores
|
||||||
{
|
{
|
||||||
get { return scores; }
|
get { return scores; }
|
||||||
@ -59,22 +60,28 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
// ensure placeholder is hidden when displaying scores
|
// ensure placeholder is hidden when displaying scores
|
||||||
PlaceholderState = PlaceholderState.Successful;
|
PlaceholderState = PlaceholderState.Successful;
|
||||||
|
|
||||||
// schedule because we may not be loaded yet (LoadComponentAsync complains).
|
var flow = scrollFlow = new FillFlowContainer<LeaderboardScore>
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
LoadComponentAsync(new FillFlowContainer<LeaderboardScore>
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Spacing = new Vector2(0f, 5f),
|
Spacing = new Vector2(0f, 5f),
|
||||||
Padding = new MarginPadding { Top = 10, Bottom = 5 },
|
Padding = new MarginPadding { Top = 10, Bottom = 5 },
|
||||||
ChildrenEnumerable = scores.Select((s, index) => new LeaderboardScore(s, index + 1) { Action = () => ScoreSelected?.Invoke(s) })
|
ChildrenEnumerable = scores.Select((s, index) => new LeaderboardScore(s, index + 1) { Action = () => ScoreSelected?.Invoke(s) })
|
||||||
}, f =>
|
};
|
||||||
|
|
||||||
|
// schedule because we may not be loaded yet (LoadComponentAsync complains).
|
||||||
|
showScoresDelegate?.Cancel();
|
||||||
|
if (!IsLoaded)
|
||||||
|
showScoresDelegate = Schedule(showScores);
|
||||||
|
else
|
||||||
|
showScores();
|
||||||
|
|
||||||
|
void showScores() => LoadComponentAsync(flow, _ =>
|
||||||
{
|
{
|
||||||
scrollContainer.Add(scrollFlow = f);
|
scrollContainer.Add(flow);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var s in f.Children)
|
foreach (var s in flow.Children)
|
||||||
{
|
{
|
||||||
using (s.BeginDelayedSequence(i++ * 50, true))
|
using (s.BeginDelayedSequence(i++ * 50, true))
|
||||||
s.Show();
|
s.Show();
|
||||||
@ -82,7 +89,6 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
scrollContainer.ScrollTo(0f, false);
|
scrollContainer.ScrollTo(0f, false);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +109,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
private PlaceholderState placeholderState;
|
private PlaceholderState placeholderState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the placeholder visibility.
|
||||||
|
/// Setting this to anything other than PlaceholderState.Successful will cancel all existing retrieval requests and hide scores.
|
||||||
|
/// </summary>
|
||||||
protected PlaceholderState PlaceholderState
|
protected PlaceholderState PlaceholderState
|
||||||
{
|
{
|
||||||
get { return placeholderState; }
|
get { return placeholderState; }
|
||||||
@ -250,43 +260,45 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
loading.Show();
|
loading.Show();
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope);
|
getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope);
|
||||||
getScoresRequest.Success += r =>
|
getScoresRequest.Success += r => Schedule(() =>
|
||||||
{
|
{
|
||||||
Scores = r.Scores;
|
Scores = r.Scores;
|
||||||
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
|
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
|
||||||
};
|
});
|
||||||
getScoresRequest.Failure += onUpdateFailed;
|
|
||||||
|
|
||||||
api.Queue(getScoresRequest);
|
getScoresRequest.Failure += e => Schedule(() =>
|
||||||
}
|
|
||||||
|
|
||||||
private void onUpdateFailed(Exception e)
|
|
||||||
{
|
{
|
||||||
if (e is OperationCanceledException)
|
if (e is OperationCanceledException)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlaceholderState = PlaceholderState.NetworkFailure;
|
PlaceholderState = PlaceholderState.NetworkFailure;
|
||||||
Logger.Error(e, @"Couldn't fetch beatmap scores!");
|
Logger.Error(e, @"Couldn't fetch beatmap scores!");
|
||||||
|
});
|
||||||
|
|
||||||
|
api.Queue(getScoresRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Placeholder currentPlaceholder;
|
||||||
|
|
||||||
private void replacePlaceholder(Placeholder placeholder)
|
private void replacePlaceholder(Placeholder placeholder)
|
||||||
{
|
{
|
||||||
var existingPlaceholder = placeholderContainer.Children.LastOrDefault() as Placeholder;
|
if (placeholder != null && placeholder.Equals(currentPlaceholder))
|
||||||
|
|
||||||
if (placeholder != null && placeholder.Equals(existingPlaceholder))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
existingPlaceholder?.FadeOut(150, Easing.OutQuint).Expire();
|
currentPlaceholder?.FadeOut(150, Easing.OutQuint).Expire();
|
||||||
|
|
||||||
if (placeholder == null)
|
if (placeholder == null)
|
||||||
|
{
|
||||||
|
currentPlaceholder = null;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Scores = null;
|
placeholderContainer.Child = placeholder;
|
||||||
|
|
||||||
placeholderContainer.Add(placeholder);
|
|
||||||
|
|
||||||
placeholder.ScaleTo(0.8f).Then().ScaleTo(1, fade_duration * 3, Easing.OutQuint);
|
placeholder.ScaleTo(0.8f).Then().ScaleTo(1, fade_duration * 3, Easing.OutQuint);
|
||||||
placeholder.FadeInFromZero(fade_duration, Easing.OutQuint);
|
placeholder.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
currentPlaceholder = placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
20
osu.Game/Users/Badge.cs
Normal file
20
osu.Game/Users/Badge.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace osu.Game.Users
|
||||||
|
{
|
||||||
|
public class Badge
|
||||||
|
{
|
||||||
|
[JsonProperty("awarded_at")]
|
||||||
|
public DateTimeOffset AwardedAt;
|
||||||
|
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
[JsonProperty("image_url")]
|
||||||
|
public string ImageUrl;
|
||||||
|
}
|
||||||
|
}
|
@ -137,6 +137,9 @@ namespace osu.Game.Users
|
|||||||
[JsonProperty(@"rankHistory")]
|
[JsonProperty(@"rankHistory")]
|
||||||
public RankHistoryData RankHistory;
|
public RankHistoryData RankHistory;
|
||||||
|
|
||||||
|
[JsonProperty("badges")]
|
||||||
|
public Badge[] Badges;
|
||||||
|
|
||||||
public override string ToString() => Username;
|
public override string ToString() => Username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays.Profile;
|
using osu.Game.Overlays.Profile.Header;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user