1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 14:07:52 +08:00
osu-lazer/osu.Game/Overlays/Profile/Sections/RanksSection.cs

167 lines
5.6 KiB
C#
Raw Normal View History

2017-06-07 22:49:14 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-07-27 00:55:37 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
2017-07-27 00:55:37 +08:00
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Profile.Sections.Ranks;
2017-07-29 06:31:52 +08:00
using osu.Game.Rulesets.Scoring;
2017-07-27 00:55:37 +08:00
using System;
using System.Linq;
2017-07-27 00:55:37 +08:00
2017-07-13 12:53:45 +08:00
namespace osu.Game.Overlays.Profile.Sections
2017-06-07 22:49:14 +08:00
{
public class RanksSection : ProfileSection
{
public override string Title => "Ranks";
2017-06-15 23:47:34 +08:00
public override string Identifier => "top_ranks";
2017-07-27 00:55:37 +08:00
private readonly ScoreFlowContainer best, first;
private readonly OsuSpriteText bestMissing, firstMissing;
2017-07-27 00:55:37 +08:00
public RanksSection()
{
Children = new Drawable[]
{
new OsuSpriteText
{
2017-07-27 00:55:37 +08:00
TextSize = 15,
Text = "Best Performance",
Font = "Exo2.0-RegularItalic",
Margin = new MarginPadding { Top = 10, Bottom = 10 },
2017-07-27 00:55:37 +08:00
},
best = new ScoreFlowContainer
2017-07-27 00:55:37 +08:00
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
bestMissing = new OsuSpriteText
{
TextSize = 14,
Text = "No awesome performance records yet. :(",
},
new OsuSpriteText
{
2017-07-27 00:55:37 +08:00
TextSize = 15,
Text = "First Place Ranks",
Font = "Exo2.0-RegularItalic",
Margin = new MarginPadding { Top = 20, Bottom = 10 },
2017-07-27 00:55:37 +08:00
},
first = new ScoreFlowContainer
2017-07-27 00:55:37 +08:00
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
firstMissing = new OsuSpriteText
{
TextSize = 14,
Text = "No awesome performance records yet. :(",
2017-07-27 00:55:37 +08:00
},
};
}
public Score[] ScoresBest
2017-07-27 00:55:37 +08:00
{
set
{
best.Clear();
if (value.Length == 0)
2017-07-27 00:55:37 +08:00
{
bestMissing.Show();
}
else
{
bestMissing.Hide();
int i = 0;
foreach (Score score in value)
2017-07-27 00:55:37 +08:00
{
best.Add(new DrawableScore(score, Math.Pow(0.95, i))
{
RelativeSizeAxes = Axes.X,
Height = 60,
Alpha = 0,
});
i++;
}
2017-07-27 00:55:37 +08:00
}
best.ShowMore();
2017-07-27 00:55:37 +08:00
}
}
public Score[] ScoresFirst
2017-07-27 00:55:37 +08:00
{
set
{
first.Clear();
if (value.Length == 0)
{
firstMissing.Show();
}
else
{
firstMissing.Hide();
foreach (Score score in value)
first.Add(new DrawableScore(score)
{
RelativeSizeAxes = Axes.X,
Height = 60,
Alpha = 0,
});
}
first.ShowMore();
}
}
2017-08-10 01:20:41 +08:00
public class ScoreFlowContainer : Container<DrawableScore>
{
private FillFlowContainer<DrawableScore> scores;
private OsuClickableContainer showMoreText;
protected override Container<DrawableScore> Content => scores;
protected override void LoadComplete()
{
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Children = new Drawable[]
2017-07-27 00:55:37 +08:00
{
2017-07-29 21:16:31 +08:00
scores = new FillFlowContainer<DrawableScore>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
},
},
};
}
public override void Clear(bool disposeChildren)
{
base.Clear(disposeChildren);
2017-08-10 04:58:06 +08:00
if (showMoreText == null)
((FillFlowContainer)InternalChild).Add(showMoreText = new OsuHoverContainer
{
Action = ShowMore,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Child = new OsuSpriteText
{
TextSize = 14,
Text = "show more",
}
});
else
showMoreText.Show();
}
2017-08-10 00:57:55 +08:00
public void ShowMore() => showMoreText.Alpha = Children.Where(d => !d.IsPresent).Where((d, i) => (d.Alpha = i < 5 ? 1 : 0) == 0).Any() ? 1 : 0;
2017-07-27 00:55:37 +08:00
}
2017-06-07 22:49:14 +08:00
}
}