mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:42:55 +08:00
some renaming, a show more button and a placeholder if no scores exist
This commit is contained in:
parent
c02165c820
commit
cca49d6ed5
@ -39,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Add First Place", () => ranks.FirstPlaceScores = new[]
|
AddStep("Add First Place", () => ranks.ScoresFirst = new[]
|
||||||
{
|
{
|
||||||
new Score
|
new Score
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
if(i < availableMods.Length)
|
if(i < availableMods.Length)
|
||||||
selectedMods.Remove(availableMods[i]);
|
selectedMods.Remove(availableMods[i]);
|
||||||
}
|
}
|
||||||
ranks.BestScores = scores;
|
ranks.ScoresBest = scores.ToArray();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
// 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 OpenTK.Graphics;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Profile.Sections.Ranks;
|
using osu.Game.Overlays.Profile.Sections.Ranks;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Sections
|
namespace osu.Game.Overlays.Profile.Sections
|
||||||
{
|
{
|
||||||
@ -17,64 +21,178 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
|
|
||||||
public override string Identifier => "top_ranks";
|
public override string Identifier => "top_ranks";
|
||||||
|
|
||||||
private readonly FillFlowContainer<DrawableScore> best, firstPlace;
|
private readonly ScoreFlowContainer best, first;
|
||||||
|
private readonly OsuSpriteText bestMissing, firstMissing;
|
||||||
|
|
||||||
public RanksSection()
|
public RanksSection()
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText {
|
new OsuSpriteText
|
||||||
|
{
|
||||||
TextSize = 15,
|
TextSize = 15,
|
||||||
Text = "Best Performance",
|
Text = "Best Performance",
|
||||||
Font = "Exo2.0-RegularItalic",
|
Font = "Exo2.0-RegularItalic",
|
||||||
|
Margin = new MarginPadding { Top = 10, Bottom = 10 },
|
||||||
},
|
},
|
||||||
best = new FillFlowContainer<DrawableScore>
|
best = new ScoreFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
},
|
},
|
||||||
new OsuSpriteText {
|
bestMissing = new OsuSpriteText
|
||||||
|
{
|
||||||
|
TextSize = 14,
|
||||||
|
Text = "No awesome performance records yet. :(",
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
TextSize = 15,
|
TextSize = 15,
|
||||||
Text = "First Place Ranks",
|
Text = "First Place Ranks",
|
||||||
Font = "Exo2.0-RegularItalic",
|
Font = "Exo2.0-RegularItalic",
|
||||||
|
Margin = new MarginPadding { Top = 20, Bottom = 10 },
|
||||||
},
|
},
|
||||||
firstPlace = new FillFlowContainer<DrawableScore>
|
first = new ScoreFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Direction = FillDirection.Vertical,
|
},
|
||||||
|
firstMissing = new OsuSpriteText
|
||||||
|
{
|
||||||
|
TextSize = 14,
|
||||||
|
Text = "No awesome performance records yet. :(",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Score> BestScores
|
public Score[] ScoresBest
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
int i = 0;
|
best.Clear();
|
||||||
foreach (Score score in value)
|
if (value.Length == 0)
|
||||||
{
|
{
|
||||||
best.Add(new DrawableScore(score, Math.Pow(0.95, i))
|
bestMissing.Show();
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 60,
|
|
||||||
});
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bestMissing.Hide();
|
||||||
|
int i = 0;
|
||||||
|
foreach (Score score in value)
|
||||||
|
{
|
||||||
|
best.Add(new DrawableScore(score, Math.Pow(0.95, i))
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 60,
|
||||||
|
});
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
best.ShowMore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Score> FirstPlaceScores
|
public Score[] ScoresFirst
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
foreach (Score score in value)
|
first.Clear();
|
||||||
firstPlace.Add(new DrawableScore(score)
|
if (value.Length == 0)
|
||||||
|
{
|
||||||
|
firstMissing.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstMissing.Hide();
|
||||||
|
foreach (Score score in value)
|
||||||
|
first.Add(new DrawableScore(score)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 60,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
first.ShowMore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ScoreFlowContainer : Container<DrawableScore>
|
||||||
|
{
|
||||||
|
private readonly FillFlowContainer<DrawableScore> scores;
|
||||||
|
private readonly OsuClickableContainer showMoreText;
|
||||||
|
|
||||||
|
protected override Container<DrawableScore> Content => scores;
|
||||||
|
|
||||||
|
private int shownScores;
|
||||||
|
|
||||||
|
public ScoreFlowContainer()
|
||||||
|
{
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
scores = new FillFlowContainer<DrawableScore>()
|
||||||
Height = 60,
|
{
|
||||||
});
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
},
|
||||||
|
showMoreText = new ShowMoreContainer
|
||||||
|
{
|
||||||
|
Action = ShowMore,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
Child = new OsuSpriteText
|
||||||
|
{
|
||||||
|
TextSize = 14,
|
||||||
|
Text = "show more",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear(bool disposeChildren)
|
||||||
|
{
|
||||||
|
base.Clear(disposeChildren);
|
||||||
|
shownScores = 0;
|
||||||
|
showMoreText.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowMore()
|
||||||
|
{
|
||||||
|
shownScores = Math.Min(Children.Count, shownScores + 5);
|
||||||
|
int i = 0;
|
||||||
|
foreach(DrawableScore score in Children)
|
||||||
|
score.FadeTo(i++ < shownScores ? 1 : 0);
|
||||||
|
showMoreText.FadeTo(shownScores == Children.Count ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ShowMoreContainer : OsuClickableContainer
|
||||||
|
{
|
||||||
|
private Color4 hoverColour;
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
this.FadeColour(hoverColour, 500, Easing.OutQuint);
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
this.FadeColour(Color4.White, 500, Easing.OutQuint);
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
hoverColour = colours.Yellow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user