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

Cleanup + fix up score table layout

This commit is contained in:
smoogipoo 2019-03-26 17:38:56 +09:00
parent f4aeb390ef
commit adab31fd58
9 changed files with 401 additions and 661 deletions

View File

@ -25,7 +25,11 @@ namespace osu.Game.Tests.Visual.Online
{
typeof(Header),
typeof(ClickableUserContainer),
typeof(ScoreTableScore),
typeof(ScoreTable),
typeof(ScoreTableRow),
typeof(ScoreTableHeaderRow),
typeof(ScoreTableScoreRow),
typeof(ScoreTableRowBackground),
typeof(DrawableTopScore),
typeof(ScoresContainer),
typeof(AuthorInfo),

View File

@ -28,8 +28,9 @@ namespace osu.Game.Tests.Visual.SongSelect
typeof(ScoresContainer),
typeof(ScoreTable),
typeof(ScoreTableRow),
typeof(ScoreTableHeader),
typeof(ScoreTableScore)
typeof(ScoreTableHeaderRow),
typeof(ScoreTableScoreRow),
typeof(ScoreTableRowBackground),
};
private readonly Box background;

View File

@ -6,203 +6,74 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTable : CompositeDrawable
{
private const int fade_duration = 100;
private const int text_size = 14;
private readonly FillFlowContainer scoresFlow;
private readonly ScoresGrid scoresGrid;
private readonly FillFlowContainer backgroundFlow;
public ScoreTable()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChild = scoresGrid = new ScoresGrid
InternalChildren = new Drawable[]
{
RelativeSizeAxes = Axes.X,
ColumnDimensions = new[]
backgroundFlow = new FillFlowContainer
{
new Dimension(GridSizeMode.Absolute, 40),
new Dimension(GridSizeMode.Absolute, 70),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Distributed, minSize: 180),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70),
new Dimension(GridSizeMode.AutoSize),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 25 }
},
scoresGrid = new ScoresGrid
{
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, 40),
new Dimension(GridSizeMode.Absolute, 70),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Distributed, minSize: 150),
new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 50, maxSize: 70),
new Dimension(GridSizeMode.Distributed, minSize: 40, maxSize: 70),
new Dimension(GridSizeMode.AutoSize),
}
}
};
scoresFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
};
}
public IEnumerable<APIScoreInfo> Scores
{
set
{
scoresFlow.Clear();
if (value == null || !value.Any())
return;
int maxModsAmount = 0;
foreach (var s in value)
{
var scoreModsAmount = s.Mods.Length;
if (scoreModsAmount > maxModsAmount)
maxModsAmount = scoreModsAmount;
}
scoresFlow.Add(new ScoreTableHeader(maxModsAmount));
var content = new List<Drawable[]> { new ScoreTableHeaderRow().CreateDrawables().ToArray() };
int index = 0;
foreach (var s in value)
scoresFlow.Add(new ScoreTableScore(index++, s, maxModsAmount));
content.Add(new ScoreTableScoreRow(index++, s).CreateDrawables().ToArray());
scoresGrid.Content = value.Select((s, i) => createRowContents(s, i).ToArray()).ToArray();
scoresGrid.Content = content.ToArray();
backgroundFlow.Clear();
for (int i = 0; i < index; i++)
backgroundFlow.Add(new ScoreTableRowBackground(i));
}
}
private IEnumerable<Drawable> createRowContents(APIScoreInfo score, int index)
{
yield return new SpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Text = $"#{index + 1}",
Font = @"Exo2.0-Bold",
TextSize = text_size,
};
yield return new DrawableRank(score.Rank)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(30, 20),
FillMode = FillMode.Fit,
};
yield return new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Right = 20 },
Text = $@"{score.TotalScore:N0}",
TextSize = text_size,
Font = index == 0 ? OsuFont.GetFont(weight: FontWeight.Bold) : OsuFont.Default
};
yield return new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Right = 20 },
Text = $@"{score.Accuracy:P2}",
TextSize = text_size,
Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White
};
yield return new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new DrawableFlag(score.User.Country)
{
Size = new Vector2(20, 13),
},
new ClickableScoreUsername
{
User = score.User,
}
}
};
yield return new SpriteText
{
Text = $@"{score.MaxCombo:N0}x",
TextSize = text_size,
};
yield return new SpriteText
{
Text = $"{score.Statistics[HitResult.Great]}",
TextSize = text_size,
Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White
};
yield return new SpriteText
{
Text = $"{score.Statistics[HitResult.Good]}",
TextSize = text_size,
Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White
};
yield return new SpriteText
{
Text = $"{score.Statistics[HitResult.Meh]}",
TextSize = text_size,
Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White
};
yield return new SpriteText
{
Text = $"{score.Statistics[HitResult.Miss]}",
TextSize = text_size,
Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White
};
yield return new SpriteText
{
Text = $@"{score.PP:N0}",
TextSize = text_size,
};
yield return new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f),
})
};
}
private class ScoresGrid : GridContainer
{
public ScoresGrid()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
@ -217,49 +88,5 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}
}
}
private class ClickableScoreUsername : ClickableUserContainer
{
private readonly SpriteText text;
private readonly SpriteText textBold;
public ClickableScoreUsername()
{
Add(text = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
});
Add(textBold = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
Font = @"Exo2.0-Bold",
Alpha = 0,
});
}
protected override void OnUserChange(User user)
{
text.Text = textBold.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
textBold.FadeIn(fade_duration, Easing.OutQuint);
text.FadeOut(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
textBold.FadeOut(fade_duration, Easing.OutQuint);
text.FadeIn(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
}
}

View File

@ -1,70 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableHeader : ScoreTableRow
{
public ScoreTableHeader(int maxModsAmount)
: base(maxModsAmount)
{
RankContainer.Add(new ScoreText
{
Text = @"rank".ToUpper(),
});
ScoreContainer.Add(new ScoreText
{
Text = @"score".ToUpper(),
});
AccuracyContainer.Add(new ScoreText
{
Text = @"accuracy".ToUpper(),
});
PlayerContainer.Add(new ScoreText
{
Text = @"player".ToUpper(),
});
MaxComboContainer.Add(new ScoreText
{
Text = @"max combo".ToUpper(),
});
HitGreatContainer.Add(new ScoreText
{
Text = "300".ToUpper(),
});
HitGoodContainer.Add(new ScoreText
{
Text = "100".ToUpper(),
});
HitMehContainer.Add(new ScoreText
{
Text = "50".ToUpper(),
});
HitMissContainer.Add(new ScoreText
{
Text = @"misses".ToUpper(),
});
PPContainer.Add(new ScoreText
{
Text = @"pp".ToUpper(),
});
ModsContainer.Add(new ScoreText
{
Text = @"mods".ToUpper(),
});
}
private class ScoreText : SpriteText
{
private const float text_size = 12;
public ScoreText()
{
TextSize = text_size;
Font = @"Exo2.0-Black";
}
}
}
}

View File

@ -0,0 +1,46 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableHeaderRow : ScoreTableRow
{
protected override Drawable CreateIndexCell() => new CellText("rank");
protected override Drawable CreateRankCell() => new Container();
protected override Drawable CreateScoreCell() => new CellText("score");
protected override Drawable CreateAccuracyCell() => new CellText("accuracy");
protected override Drawable CreatePlayerCell() => new CellText("player");
protected override IEnumerable<Drawable> CreateStatisticsCells() => new[]
{
new CellText("max combo"),
new CellText("300"),
new CellText("100"),
new CellText("50"),
new CellText("miss"),
};
protected override Drawable CreatePpCell() => new CellText("pp");
protected override Drawable CreateModsCell() => new CellText("mods");
private class CellText : OsuSpriteText
{
public CellText(string text)
{
Text = text.ToUpper();
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black);
}
}
}
}

View File

@ -1,183 +1,103 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableRow : GridContainer
public abstract class ScoreTableRow
{
private const float rank_position = 30;
private const float drawable_rank_position = 45;
private const float score_position = 90;
private const float accuracy_position = 170;
private const float flag_position = 220;
private const float player_position = 250;
protected const int TEXT_SIZE = 14;
private const float max_combo_position = 0.1f;
private const float hit_great_position = 0.3f;
private const float hit_good_position = 0.45f;
private const float hit_meh_position = 0.6f;
private const float hit_miss_position = 0.75f;
private const float pp_position = 0.9f;
protected readonly Container RankContainer;
protected readonly Container DrawableRankContainer;
protected readonly Container ScoreContainer;
protected readonly Container AccuracyContainer;
protected readonly Container FlagContainer;
protected readonly Container PlayerContainer;
protected readonly Container MaxComboContainer;
protected readonly Container HitGreatContainer;
protected readonly Container HitGoodContainer;
protected readonly Container HitMehContainer;
protected readonly Container HitMissContainer;
protected readonly Container PPContainer;
protected readonly Container ModsContainer;
public ScoreTableRow(int maxModsAmount)
public IEnumerable<Drawable> CreateDrawables()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
RowDimensions = new[]
yield return new Container
{
new Dimension(GridSizeMode.Absolute, 25),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
Child = CreateIndexCell()
};
ColumnDimensions = new[]
yield return new Container
{
new Dimension(GridSizeMode.Absolute, 300),
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Child = CreateRankCell()
};
Content = new[]
yield return new Container
{
new Drawable[]
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = 20 },
Child = CreateScoreCell()
};
yield return new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = 20 },
Child = CreateAccuracyCell()
};
yield return new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = 20 },
Child = CreatePlayerCell()
};
foreach (var cell in CreateStatisticsCells())
{
yield return new Container
{
new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
RankContainer = new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
X = rank_position,
},
DrawableRankContainer = new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = drawable_rank_position,
},
ScoreContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = score_position,
},
AccuracyContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = accuracy_position,
},
FlagContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = flag_position,
},
PlayerContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = player_position,
}
}
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
MaxComboContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = max_combo_position,
},
HitGreatContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = hit_great_position,
},
HitGoodContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = hit_good_position,
},
HitMehContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = hit_meh_position,
},
HitMissContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = hit_miss_position,
},
PPContainer = new Container
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = pp_position,
}
}
},
new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = ModsContainer = new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
X = -30 * ((maxModsAmount == 0) ? 1 : maxModsAmount),
}
}
}
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Child = cell
};
}
yield return new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Child = CreatePpCell()
};
yield return new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Child = CreateModsCell()
};
}
protected abstract Drawable CreateIndexCell();
protected abstract Drawable CreateRankCell();
protected abstract Drawable CreateScoreCell();
protected abstract Drawable CreateAccuracyCell();
protected abstract Drawable CreatePlayerCell();
protected abstract IEnumerable<Drawable> CreateStatisticsCells();
protected abstract Drawable CreatePpCell();
protected abstract Drawable CreateModsCell();
}
}

View File

@ -0,0 +1,64 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableRowBackground : CompositeDrawable
{
private const int fade_duration = 100;
private readonly Box hoveredBackground;
private readonly Box background;
public ScoreTableRowBackground(int index)
{
RelativeSizeAxes = Axes.X;
Height = 25;
CornerRadius = 3;
Masking = true;
InternalChildren = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
hoveredBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
};
if (index % 2 != 0)
background.Alpha = 0;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoveredBackground.Colour = colours.Gray4;
background.Colour = colours.Gray3;
}
protected override bool OnHover(HoverEvent e)
{
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
}

View File

@ -1,220 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableScore : Container
{
private const int fade_duration = 100;
private const int text_size = 14;
private readonly Box hoveredBackground;
private readonly Box background;
public ScoreTableScore(int index, APIScoreInfo score, int maxModsAmount)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
CornerRadius = 3;
Masking = true;
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
hoveredBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
new ScoreRow(index, score, maxModsAmount),
};
if (index % 2 != 0)
background.Alpha = 0;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoveredBackground.Colour = colours.Gray4;
background.Colour = colours.Gray3;
}
protected override bool OnHover(HoverEvent e)
{
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
protected override bool OnClick(ClickEvent e) => true;
private class ClickableScoreUsername : ClickableUserContainer
{
private readonly SpriteText text;
private readonly SpriteText textBold;
public ClickableScoreUsername()
{
Add(text = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
});
Add(textBold = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextSize = text_size,
Font = @"Exo2.0-Bold",
Alpha = 0,
});
}
protected override void OnUserChange(User user)
{
text.Text = textBold.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
textBold.FadeIn(fade_duration, Easing.OutQuint);
text.FadeOut(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
textBold.FadeOut(fade_duration, Easing.OutQuint);
text.FadeIn(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
private class ScoreRow : ScoreTableRow
{
public ScoreRow(int index, APIScoreInfo score, int maxModsAmount)
: base(maxModsAmount)
{
SpriteText scoreText;
SpriteText accuracy;
SpriteText hitGreat;
SpriteText hitGood;
SpriteText hitMeh;
SpriteText hitMiss;
FillFlowContainer modsContainer;
RankContainer.Add(new SpriteText
{
Text = $"#{index + 1}",
Font = @"Exo2.0-Bold",
TextSize = text_size,
});
DrawableRankContainer.Add(new DrawableRank(score.Rank)
{
Size = new Vector2(30, 20),
FillMode = FillMode.Fit,
});
ScoreContainer.Add(scoreText = new SpriteText
{
Text = $@"{score.TotalScore:N0}",
TextSize = text_size,
});
AccuracyContainer.Add(accuracy = new SpriteText
{
Text = $@"{score.Accuracy:P2}",
TextSize = text_size,
});
FlagContainer.Add(new DrawableFlag(score.User.Country)
{
Size = new Vector2(20, 13),
});
PlayerContainer.Add(new ClickableScoreUsername
{
User = score.User,
});
MaxComboContainer.Add(new SpriteText
{
Text = $@"{score.MaxCombo:N0}x",
TextSize = text_size,
});
HitGreatContainer.Add(hitGreat = new SpriteText
{
Text = $"{score.Statistics[HitResult.Great]}",
TextSize = text_size,
});
HitGoodContainer.Add(hitGood = new SpriteText
{
Text = $"{score.Statistics[HitResult.Good]}",
TextSize = text_size,
});
HitMehContainer.Add(hitMeh = new SpriteText
{
Text = $"{score.Statistics[HitResult.Meh]}",
TextSize = text_size,
});
HitMissContainer.Add(hitMiss = new SpriteText
{
Text = $"{score.Statistics[HitResult.Miss]}",
TextSize = text_size,
});
PPContainer.Add(new SpriteText
{
Text = $@"{score.PP:N0}",
TextSize = text_size,
});
ModsContainer.Add(modsContainer = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
});
if (index == 0)
scoreText.Font = @"Exo2.0-Bold";
accuracy.Colour = (score.Accuracy == 1) ? Color4.GreenYellow : Color4.White;
hitGreat.Colour = (score.Statistics[HitResult.Great] == 0) ? Color4.Gray : Color4.White;
hitGood.Colour = (score.Statistics[HitResult.Good] == 0) ? Color4.Gray : Color4.White;
hitMeh.Colour = (score.Statistics[HitResult.Meh] == 0) ? Color4.Gray : Color4.White;
hitMiss.Colour = (score.Statistics[HitResult.Miss] == 0) ? Color4.Gray : Color4.White;
foreach (Mod mod in score.Mods)
modsContainer.Add(new ModIcon(mod)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f),
});
}
}
}
}

View File

@ -0,0 +1,168 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
public class ScoreTableScoreRow : ScoreTableRow
{
private readonly int index;
private readonly ScoreInfo score;
public ScoreTableScoreRow(int index, ScoreInfo score)
{
this.index = index;
this.score = score;
}
protected override Drawable CreateIndexCell() => new OsuSpriteText
{
Text = $"#{index + 1}",
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
};
protected override Drawable CreateRankCell() => new DrawableRank(score.Rank)
{
Size = new Vector2(30, 20),
};
protected override Drawable CreateScoreCell() => new OsuSpriteText
{
Text = $@"{score.TotalScore:N0}",
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
};
protected override Drawable CreateAccuracyCell() => new OsuSpriteText
{
Text = $@"{score.Accuracy:P2}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White
};
protected override Drawable CreatePlayerCell() => new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) },
new ClickableScoreUsername { User = score.User }
}
};
protected override IEnumerable<Drawable> CreateStatisticsCells()
{
yield return new OsuSpriteText
{
Text = $@"{score.MaxCombo:N0}x",
Font = OsuFont.GetFont(size: TEXT_SIZE)
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Great]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Good]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Meh]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Miss]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White
};
}
protected override Drawable CreatePpCell() => new OsuSpriteText
{
Text = $@"{score.PP:N0}",
Font = OsuFont.GetFont(size: TEXT_SIZE)
};
protected override Drawable CreateModsCell() => new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f)
})
};
private class ClickableScoreUsername : ClickableUserContainer
{
private const int fade_duration = 100;
private readonly SpriteText text;
private readonly SpriteText textBold;
public ClickableScoreUsername()
{
Add(text = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: TEXT_SIZE)
});
Add(textBold = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
Alpha = 0,
});
}
protected override void OnUserChange(User user)
{
text.Text = textBold.Text = user.Username;
}
protected override bool OnHover(HoverEvent e)
{
textBold.FadeIn(fade_duration, Easing.OutQuint);
text.FadeOut(fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
textBold.FadeOut(fade_duration, Easing.OutQuint);
text.FadeIn(fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
}
}
}