LeaderboardScore state, initial delay handled by leaderboard

This commit is contained in:
DrabWeb 2017-03-15 08:44:29 -03:00
parent e286356c4a
commit aea9a7b795
2 changed files with 76 additions and 58 deletions

View File

@ -3,10 +3,7 @@
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Game.Modes;
@ -39,9 +36,17 @@ public IEnumerable<Score> Scores
i = 0;
foreach(var s in scores)
{
scrollFlow.Add(new LeaderboardScore(s, 1 + i++)
var ls = new LeaderboardScore(s, 1 + i++)
{
AlwaysPresent = true
AlwaysPresent = true,
State = Visibility.Hidden,
};
scrollFlow.Add(ls);
ls.Delay(i * 50);
ls.Schedule(() =>
{
ls.Show();
});
}

View File

@ -12,13 +12,13 @@
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Colour;
using osu.Game.Modes.Mods;
using osu.Game.Users;
using osu.Framework;
namespace osu.Game.Screens.Select.Leaderboards
{
public class LeaderboardScore : Container
public class LeaderboardScore : Container, IStateful<Visibility>
{
private const float height = 70;
private const float corner_radius = 5;
@ -45,6 +45,70 @@ public class LeaderboardScore : Container
private readonly int index;
public readonly Score Score;
private Visibility state;
public Visibility State
{
get { return state; }
set
{
state = value;
switch (state)
{
case Visibility.Hidden:
foreach (Drawable d in new Drawable[] { avatar, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer, })
{
d.FadeOut();
}
Alpha = 0;
content.MoveToY(75);
avatar.MoveToX(75);
nameLabel.MoveToX(150);
break;
case Visibility.Visible:
FadeIn(200);
content.MoveToY(0, 800, EasingTypes.OutQuint);
Delay(100);
Schedule(() =>
{
avatar.FadeIn(300, EasingTypes.OutQuint);
nameLabel.FadeIn(350, EasingTypes.OutQuint);
avatar.MoveToX(0, 300, EasingTypes.OutQuint);
nameLabel.MoveToX(0, 350, EasingTypes.OutQuint);
Delay(250);
Schedule(() =>
{
scoreLabel.FadeIn(200);
scoreRank.FadeIn(200);
Delay(50);
Schedule(() =>
{
var drawables = new Drawable[] { flagBadgeContainer, maxCombo, accuracy, modsContainer, };
for (int i = 0; i < drawables.Length; i++)
{
drawables[i].FadeIn(100 + i * 50);
}
});
});
});
break;
}
}
}
public override void Hide() => State = Visibility.Hidden;
public override void Show() => State = Visibility.Visible;
public void ToggleVisibility() => State = State == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
protected override bool OnHover(Framework.Input.InputState state)
{
background.FadeTo(0.5f, 300, EasingTypes.OutQuint);
@ -57,57 +121,6 @@ protected override void OnHoverLost(Framework.Input.InputState state)
base.OnHoverLost(state);
}
protected override void LoadComplete()
{
base.LoadComplete();
foreach (Drawable d in new Drawable[] { avatar, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer, })
{
d.FadeOut();
}
Alpha = 0;
content.MoveToY(75);
avatar.MoveToX(75);
nameLabel.MoveToX(150);
Delay(index * 50);
Schedule(() =>
{
FadeIn(200);
content.MoveToY(0, 800, EasingTypes.OutQuint);
Delay(100);
Schedule(() =>
{
avatar.FadeIn(300, EasingTypes.OutQuint);
nameLabel.FadeIn(350, EasingTypes.OutQuint);
avatar.MoveToX(0, 300, EasingTypes.OutQuint);
nameLabel.MoveToX(0, 350, EasingTypes.OutQuint);
Delay(250);
Schedule(() =>
{
scoreLabel.FadeIn(200);
scoreRank.FadeIn(200);
Delay(50);
Schedule(() =>
{
var drawables = new Drawable[] { flagBadgeContainer, maxCombo, accuracy, modsContainer, };
for (int i = 0; i < drawables.Length; i++)
{
drawables[i].FadeIn(100 + i * 50);
}
});
});
});
});
}
public LeaderboardScore(Score score, int i)
{
Score = score;