mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:47:52 +08:00
Visibility improvements
This commit is contained in:
parent
eb4ef8f6ac
commit
8d6af1625a
@ -243,6 +243,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
allScores.UserScore = myBestScore;
|
||||
scoresContainer.Scores = allScores;
|
||||
});
|
||||
AddStep("Trigger loading", () => scoresContainer.Loading = !scoresContainer.Loading);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -17,13 +17,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
public class ScoresContainer : CompositeDrawable
|
||||
{
|
||||
private const int spacing = 15;
|
||||
private const int fade_duration = 200;
|
||||
private const int padding = 20;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly ScoreTable scoreTable;
|
||||
|
||||
private readonly FillFlowContainer topScoresContainer;
|
||||
private readonly LoadingAnimation loadingAnimation;
|
||||
private readonly ContentContainer resizableContainer;
|
||||
private readonly LoadingContainer loadingContainer;
|
||||
|
||||
public ScoresContainer()
|
||||
{
|
||||
@ -36,6 +37,24 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
loadingContainer = new LoadingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Masking = true,
|
||||
},
|
||||
resizableContainer = new ContentContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -45,7 +64,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Width = 0.95f,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, spacing),
|
||||
Margin = new MarginPadding { Vertical = spacing },
|
||||
Padding = new MarginPadding { Vertical = padding },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
topScoresContainer = new FillFlowContainer
|
||||
@ -62,29 +81,43 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
}
|
||||
}
|
||||
},
|
||||
loadingAnimation = new LoadingAnimation
|
||||
{
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding(20),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Loading = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.Gray2;
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private bool loading;
|
||||
|
||||
public bool Loading
|
||||
{
|
||||
get => loading;
|
||||
set
|
||||
{
|
||||
loadingAnimation.FadeTo(value ? 1 : 0, fade_duration);
|
||||
if (loading == value)
|
||||
return;
|
||||
|
||||
loading = value;
|
||||
|
||||
if (value)
|
||||
Scores = null;
|
||||
{
|
||||
loadingContainer.Show();
|
||||
resizableContainer.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingContainer.Hide();
|
||||
resizableContainer.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +150,63 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
if (userScore != null && userScore.Position != 1)
|
||||
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
||||
}
|
||||
|
||||
Loading = false;
|
||||
}
|
||||
|
||||
private class ContentContainer : VisibilityContainer
|
||||
{
|
||||
private const int duration = 300;
|
||||
|
||||
private float maxHeight;
|
||||
|
||||
protected override void PopIn() => this.ResizeHeightTo(maxHeight, duration, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.ResizeHeightTo(0, duration, Easing.OutQuint);
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (State.Value == Visibility.Hidden)
|
||||
return;
|
||||
|
||||
float height = 0;
|
||||
|
||||
foreach (var c in Children)
|
||||
{
|
||||
height += c.Height;
|
||||
}
|
||||
|
||||
maxHeight = height;
|
||||
|
||||
this.ResizeHeightTo(maxHeight, duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private class LoadingContainer : VisibilityContainer
|
||||
{
|
||||
private const int duration = 300;
|
||||
private const int height = 50;
|
||||
|
||||
private readonly LoadingAnimation loadingAnimation;
|
||||
|
||||
public LoadingContainer()
|
||||
{
|
||||
Child = loadingAnimation = new LoadingAnimation();
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.ResizeHeightTo(height, duration, Easing.OutQuint);
|
||||
loadingAnimation.Show();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.ResizeHeightTo(0, duration, Easing.OutQuint);
|
||||
loadingAnimation.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,11 +98,7 @@ namespace osu.Game.Overlays
|
||||
scores.Loading = true;
|
||||
|
||||
getScoresRequest = new GetScoresRequest(b, b.Ruleset);
|
||||
getScoresRequest.Success += r => Schedule(() =>
|
||||
{
|
||||
scores.Scores = r;
|
||||
scores.Loading = false;
|
||||
});
|
||||
getScoresRequest.Success += r => Schedule(() => scores.Scores = r);
|
||||
api.Queue(getScoresRequest);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user