mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +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;
|
allScores.UserScore = myBestScore;
|
||||||
scoresContainer.Scores = allScores;
|
scoresContainer.Scores = allScores;
|
||||||
});
|
});
|
||||||
|
AddStep("Trigger loading", () => scoresContainer.Loading = !scoresContainer.Loading);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -17,13 +17,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
public class ScoresContainer : CompositeDrawable
|
public class ScoresContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int spacing = 15;
|
private const int spacing = 15;
|
||||||
private const int fade_duration = 200;
|
private const int padding = 20;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly ScoreTable scoreTable;
|
private readonly ScoreTable scoreTable;
|
||||||
|
|
||||||
private readonly FillFlowContainer topScoresContainer;
|
private readonly FillFlowContainer topScoresContainer;
|
||||||
private readonly LoadingAnimation loadingAnimation;
|
private readonly ContentContainer resizableContainer;
|
||||||
|
private readonly LoadingContainer loadingContainer;
|
||||||
|
|
||||||
public ScoresContainer()
|
public ScoresContainer()
|
||||||
{
|
{
|
||||||
@ -38,53 +39,85 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Width = 0.95f,
|
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Spacing = new Vector2(0, spacing),
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Vertical = spacing },
|
RelativeSizeAxes = Axes.X,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
topScoresContainer = new FillFlowContainer
|
loadingContainer = new LoadingContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
Masking = true,
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(0, 5),
|
|
||||||
},
|
},
|
||||||
scoreTable = new ScoreTable
|
resizableContainer = new ContentContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.TopCentre,
|
Masking = true,
|
||||||
}
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Width = 0.95f,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(0, spacing),
|
||||||
|
Padding = new MarginPadding { Vertical = padding },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
topScoresContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(0, 5),
|
||||||
|
},
|
||||||
|
scoreTable = new ScoreTable
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
loadingAnimation = new LoadingAnimation
|
|
||||||
{
|
|
||||||
Alpha = 0,
|
|
||||||
Margin = new MarginPadding(20),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
background.Colour = colours.Gray2;
|
background.Colour = colours.Gray2;
|
||||||
updateDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool loading;
|
||||||
|
|
||||||
public bool Loading
|
public bool Loading
|
||||||
{
|
{
|
||||||
|
get => loading;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
loadingAnimation.FadeTo(value ? 1 : 0, fade_duration);
|
if (loading == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
loading = value;
|
||||||
|
|
||||||
if (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)
|
if (userScore != null && userScore.Position != 1)
|
||||||
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
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;
|
scores.Loading = true;
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(b, b.Ruleset);
|
getScoresRequest = new GetScoresRequest(b, b.Ruleset);
|
||||||
getScoresRequest.Success += r => Schedule(() =>
|
getScoresRequest.Success += r => Schedule(() => scores.Scores = r);
|
||||||
{
|
|
||||||
scores.Scores = r;
|
|
||||||
scores.Loading = false;
|
|
||||||
});
|
|
||||||
api.Queue(getScoresRequest);
|
api.Queue(getScoresRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user