mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 09:37:23 +08:00
Merge branch 'master' into fix-storyboard-sprite-paths
This commit is contained in:
commit
20f9759a2e
@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private readonly OsuSpriteText placeholder;
|
private readonly OsuSpriteText placeholder;
|
||||||
|
|
||||||
private KeyValuePair<int, int>[] ranks;
|
private KeyValuePair<int, int>[] ranks;
|
||||||
private int dayIndex;
|
private int hoveredIndex = -1;
|
||||||
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
|
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
|
||||||
|
|
||||||
public RankGraph()
|
public RankGraph()
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
graph.OnBallMove += i => dayIndex = i;
|
graph.OnBallMove += i => hoveredIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -74,6 +74,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private void updateStatistics(UserStatistics statistics)
|
private void updateStatistics(UserStatistics statistics)
|
||||||
{
|
{
|
||||||
placeholder.FadeIn(fade_duration, Easing.Out);
|
placeholder.FadeIn(fade_duration, Easing.Out);
|
||||||
|
hoveredIndex = -1;
|
||||||
|
|
||||||
if (statistics?.Ranks.Global == null)
|
if (statistics?.Ranks.Global == null)
|
||||||
{
|
{
|
||||||
@ -94,13 +95,18 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
graph.FadeTo(ranks.Length > 1 ? 1 : 0, fade_duration, Easing.Out);
|
graph.FadeTo(ranks.Length > 1 ? 1 : 0, fade_duration, Easing.Out);
|
||||||
|
|
||||||
|
if (IsHovered)
|
||||||
|
graph.UpdateBallPosition(lastHoverPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float lastHoverPosition;
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (ranks?.Length > 1)
|
if (ranks?.Length > 1)
|
||||||
{
|
{
|
||||||
graph.UpdateBallPosition(e.MousePosition.X);
|
graph.UpdateBallPosition(lastHoverPosition = e.MousePosition.X);
|
||||||
graph.ShowBar();
|
graph.ShowBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,11 +123,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
if (ranks?.Length > 1)
|
graph.HideBar();
|
||||||
{
|
|
||||||
graph.HideBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +189,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
public void HideBar() => bar.FadeOut(fade_duration);
|
public void HideBar() => bar.FadeOut(fade_duration);
|
||||||
|
|
||||||
private int calculateIndex(float mouseXPosition) => (int)MathF.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1));
|
private int calculateIndex(float mouseXPosition) => (int)Math.Clamp(MathF.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1)), 0, DefaultValueCount - 1);
|
||||||
|
|
||||||
private Vector2 calculateBallPosition(int index)
|
private Vector2 calculateBallPosition(int index)
|
||||||
{
|
{
|
||||||
@ -200,14 +202,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Statistics.Value?.Ranks.Global == null)
|
if (ranks == null || hoveredIndex == -1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var days = ranked_days - ranks[dayIndex].Key + 1;
|
var days = ranked_days - ranks[hoveredIndex].Key + 1;
|
||||||
|
|
||||||
return new TooltipDisplayContent
|
return new TooltipDisplayContent
|
||||||
{
|
{
|
||||||
Rank = $"#{ranks[dayIndex].Value:#,##0}",
|
Rank = $"#{ranks[hoveredIndex].Value:#,##0}",
|
||||||
Time = days == 0 ? "now" : $"{days} days ago"
|
Time = days == 0 ? "now" : $"{days} days ago"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user