Apply suggested changes

This commit is contained in:
EVAST9919 2017-11-15 10:21:07 +03:00
parent 409d049066
commit 093ebb8b17
4 changed files with 56 additions and 77 deletions

View File

@ -18,6 +18,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private User user;
public User User
{
get { return user; }
set
{
if (user == value) return;
@ -25,7 +26,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
text.Text = user.Username;
}
get { return user; }
}
public float TextSize
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
protected override bool OnClick(InputState state)
{
profile?.ShowUser(user);
return base.OnClick(state);
return true;
}
}
}

View File

@ -21,10 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public class DrawableScore : Container
{
private const int fade_duration = 100;
private const float height = 30;
private const float side_margin = 20;
private const float flag_margin = 60;
private const float username_margin = 100;
private readonly Box background;
@ -33,7 +30,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
ScoreModsContainer modsContainer;
RelativeSizeAxes = Axes.X;
Height = height;
Height = 30;
CornerRadius = 3;
Masking = true;
Children = new Drawable[]
@ -55,16 +52,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = 30,
Height = 20,
Margin = new MarginPadding { Left = flag_margin }
Size = new Vector2(30, 20),
Margin = new MarginPadding { Left = 60 }
},
new ClickableUsername
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
User = score.User,
Margin = new MarginPadding { Left = username_margin }
Margin = new MarginPadding { Left = 100 }
},
modsContainer = new ScoreModsContainer
{
@ -72,16 +68,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Width = 0.05f,
Width = 0.06f,
RelativePositionAxes = Axes.X,
X = 0.45f
X = 0.42f
},
new DrawableRank(score.Rank)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = 30,
Height = 20,
Size = new Vector2(30, 20),
FillMode = FillMode.Fit,
RelativePositionAxes = Axes.X,
X = 0.55f
@ -90,10 +85,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Text = $@"{score.TotalScore}",
Font = @"Exo2.0-MediumItalic",
Text = $@"{score.TotalScore:N0}",
Font = @"Venera",
RelativePositionAxes = Axes.X,
X = 0.7f
X = 0.75f,
FixedWidth = true,
},
new OsuSpriteText
{
@ -102,7 +98,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Text = $@"{score.Accuracy:P2}",
Font = @"Exo2.0-RegularItalic",
RelativePositionAxes = Axes.X,
X = 0.8f
X = 0.85f
},
new OsuSpriteText
{

View File

@ -45,14 +45,29 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private OnlineScore score;
public OnlineScore Score
{
get { return score; }
set
{
if (score == value) return;
score = value;
setScore();
avatar.User = username.User = score.User;
flag.FlagName = score.User.Country?.FlagName;
date.Text = $@"achieved {score.Date:MMM d, yyyy}";
rank.UpdateRank(score.Rank);
totalScore.Value = $@"{score.TotalScore:N0}";
accuracy.Value = $@"{score.Accuracy:P2}";
statistics.Value = $"{score.Statistics["300"]}/{score.Statistics["100"]}/{score.Statistics["50"]}";
modsContainer.Clear();
foreach (Mod mod in score.Mods)
modsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.45f),
});
}
get { return score; }
}
public DrawableTopScore()
@ -86,18 +101,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
},
flag = new DrawableFlag
{
Width = 30,
Height = 20,
Y = height / 4,
X = height / 2,
Size = new Vector2(30, 20),
Position = new Vector2(height / 2, height / 4),
},
username = new ClickableUsername
{
Origin = Anchor.BottomLeft,
TextSize = 30,
Y = height / 4,
X = height / 2,
Margin = new MarginPadding { Bottom = 4 },
Position = new Vector2(height / 2, avatar_size / 2),
},
rankText = new OsuSpriteText
{
@ -133,8 +144,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
rank = new DrawableRank(ScoreRank.F)
{
Origin = Anchor.BottomLeft,
Width = avatar_size,
Height = 40,
Size = new Vector2(avatar_size, 40),
FillMode = FillMode.Fit,
Y = height / 4,
Margin = new MarginPadding { Left = margin }
@ -143,8 +153,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
Origin = Anchor.BottomLeft,
AutoSizeAxes = Axes.Both,
X = height / 2,
Y = height / 4,
Position = new Vector2(height / 2, height / 4),
Direction = FillDirection.Horizontal,
Spacing = new Vector2(15, 0),
Children = new[]
@ -158,8 +167,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
AutoSizeAxes = Axes.Y,
Width = 80,
X = height / 2,
Y = height / 4,
Position = new Vector2(height / 2, height / 4),
}
}
},
@ -175,26 +183,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
BorderColour = rankText.Colour = colours.Yellow;
}
private void setScore()
{
avatar.User = username.User = score.User;
flag.FlagName = score.User.Country?.FlagName;
date.Text = $@"achieved {score.Date:MMM d, yyyy}";
rank.UpdateRank(score.Rank);
totalScore.Value = $@"{score.TotalScore}";
accuracy.Value = $@"{score.Accuracy:P2}";
statistics.Value = $"{score.Statistics["300"]}/{score.Statistics["100"]}/{score.Statistics["50"]}";
modsContainer.Clear();
foreach (Mod mod in score.Mods)
modsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.45f),
});
}
protected override bool OnHover(InputState state)
{
background.FadeIn(fade_duration, Easing.OutQuint);

View File

@ -27,6 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private bool isLoading;
public bool IsLoading
{
get { return isLoading; }
set
{
if (isLoading == value) return;
@ -35,18 +36,33 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
foreground.FadeTo(isLoading ? 1 : 0, fade_duration);
loadingAnimation.FadeTo(isLoading ? 1 : 0, fade_duration);
}
get { return isLoading; }
}
private IEnumerable<OnlineScore> scores;
public IEnumerable<OnlineScore> Scores
{
get { return scores; }
set
{
scores = value;
updateScores();
var scoresAmount = scores.Count();
if (scoresAmount == 0)
{
CleanAllScores();
return;
}
topScore.Score = scores.FirstOrDefault();
topScore.Show();
flow.Clear();
if (scoresAmount < 2)
return;
for (int i = 1; i < scoresAmount; i++)
flow.Add(new DrawableScore(i, scores.ElementAt(i)));
}
get { return scores; }
}
public ScoresContainer()
@ -90,27 +106,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
};
}
private void updateScores()
{
var scoresAmount = scores.Count();
if (scoresAmount == 0)
{
CleanAllScores();
return;
}
topScore.Score = scores.FirstOrDefault();
topScore.Show();
flow.Clear();
if (scoresAmount < 2)
return;
for (int i = 1; i < scoresAmount; i++)
flow.Add(new DrawableScore(i, scores.ElementAt(i)));
}
public void CleanAllScores()
{
topScore.Hide();