1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:43:01 +08:00

Revert animations and apply suggested changes

This commit is contained in:
Andrei Zavatski 2019-07-09 17:38:17 +03:00
parent bdcdb3a7a6
commit 9907a58ec4
5 changed files with 45 additions and 119 deletions

View File

@ -244,7 +244,6 @@ namespace osu.Game.Tests.Visual.Online
allScores.UserScore = myBestScore;
scoresContainer.Scores = allScores;
});
AddStep("Trigger loading", () => scoresContainer.Loading = !scoresContainer.Loading);
}
}
}

View File

@ -59,11 +59,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
new Drawable[]
{
new TopScoreUserSection(position)
new TopScoreUserSection
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Score = score,
ScorePosition = position,
},
null,
new TopScoreStatisticsSection

View File

@ -17,20 +17,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public class ScoresContainer : CompositeDrawable
{
private const int spacing = 15;
private const int padding = 20;
private const int fade_duration = 200;
private readonly Box background;
private readonly ScoreTable scoreTable;
private readonly FillFlowContainer topScoresContainer;
private readonly ContentContainer contentContainer;
private readonly LoadingContainer loadingContainer;
private readonly LoadingAnimation loadingAnimation;
public ScoresContainer()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{
background = new Box
@ -39,83 +36,53 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
},
new FillFlowContainer
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Width = 0.95f,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, spacing),
Margin = new MarginPadding { Vertical = spacing },
Children = new Drawable[]
{
loadingContainer = new LoadingContainer
topScoresContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
Masking = true,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
},
contentContainer = new ContentContainer
scoreTable = new ScoreTable
{
RelativeSizeAxes = Axes.X,
Masking = true,
Child = 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,
}
},
}
},
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
}
},
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
{
loading = value;
loadingAnimation.FadeTo(value ? 1 : 0, fade_duration);
if (value)
{
loadingContainer.Show();
contentContainer.Hide();
}
else
{
loadingContainer.Hide();
if (scores == null || scores?.Scores.Count < 1)
contentContainer.Hide();
else
contentContainer.Show();
}
Scores = null;
}
}
@ -139,7 +106,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
scoreTable.Scores = scores?.Scores.Count > 1 ? scores.Scores : new List<APILegacyScoreInfo>();
scoreTable.FadeTo(scores?.Scores.Count > 1 ? 1 : 0);
if (scores?.Scores.Any() == true)
if (scores?.Scores.Any() ?? false)
{
topScoresContainer.Add(new DrawableTopScore(scores.Scores.FirstOrDefault()));
@ -148,56 +115,6 @@ 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;
maxHeight = Child.DrawHeight;
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();
}
}
}
}

View File

@ -28,7 +28,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly SpriteText date;
private readonly UpdateableFlag flag;
public TopScoreUserSection(int position)
public int ScorePosition
{
set => rankText.Text = $"#{value}";
}
public TopScoreUserSection()
{
AutoSizeAxes = Axes.Both;
@ -52,7 +57,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = $"#{position.ToString()}",
Text = $"#1",
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
},
rank = new UpdateableRank(ScoreRank.D)

View File

@ -17,17 +17,14 @@ using osu.Game.Overlays.BeatmapSet;
using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets;
using osuTK;
namespace osu.Game.Overlays
{
public class BeatmapSetOverlay : FullscreenOverlay
{
private const int fade_duration = 300;
public const float X_PADDING = 40;
public const float TOP_PADDING = 25;
public const float RIGHT_WIDTH = 275;
protected readonly Header Header;
private RulesetStore rulesets;
@ -46,7 +43,6 @@ namespace osu.Game.Overlays
{
OsuScrollContainer scroll;
Info info;
Children = new Drawable[]
{
new Box
@ -98,7 +94,11 @@ namespace osu.Game.Overlays
scores.Loading = true;
getScoresRequest = new GetScoresRequest(b, b.Ruleset);
getScoresRequest.Success += r => Schedule(() => scores.Scores = r);
getScoresRequest.Success += r => Schedule(() =>
{
scores.Scores = r;
scores.Loading = false;
});
api.Queue(getScoresRequest);
}
@ -123,6 +123,7 @@ namespace osu.Game.Overlays
public void FetchAndShowBeatmap(int beatmapId)
{
beatmapSet.Value = null;
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
req.Success += res =>
{
@ -130,15 +131,18 @@ namespace osu.Game.Overlays
Header.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
};
API.Queue(req);
Show();
}
public void FetchAndShowBeatmapSet(int beatmapSetId)
{
beatmapSet.Value = null;
var req = new GetBeatmapSetRequest(beatmapSetId);
req.Success += res => beatmapSet.Value = res.ToBeatmapSet(rulesets);
API.Queue(req);
Show();
}