Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 83 additions & 41 deletions osu.Game/Overlays/Profile/Header/Components/ExtendedDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Resources.Localisation.Web;
Expand All @@ -29,57 +31,68 @@ public partial class ExtendedDetails : CompositeDrawable
private SpriteText replaysWatched = null!;

[BackgroundDependencyLoader]
private void load()
private void load(OverlayColourProvider colourProvider)
{
var font = OsuFont.Default.With(size: 12);
const float vertical_spacing = 4;
const float horizontal_spacing = 20;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed actually, but i added it for consistency


AutoSizeAxes = Axes.Both;
CornerRadius = 6;
Masking = true;

// this should really be a grid, but trying to avoid one to avoid the performance hit.
InternalChild = new FillFlowContainer
InternalChildren = new Drawable[]
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
Children = new[]
new Box
{
new FillFlowContainer
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4,
},
// this should really be a grid, but trying to avoid one to avoid the performance hit.
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(horizontal_spacing, 0),
Padding = new MarginPadding { Vertical = 18, Horizontal = 12 },
Children = new[]
{
Name = @"Labels",
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, vertical_spacing),
Children = new Drawable[]
new FillFlowContainer
{
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsRankedScore },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsHitAccuracy },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsPlayCount },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsTotalScore },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsTotalHits },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsHitsPerPlay },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsMaximumCombo },
new OsuSpriteText { Font = font, Text = UsersStrings.ShowStatsReplaysWatchedByOthers },
}
},
new FillFlowContainer
{
Name = @"Values",
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, vertical_spacing),
Children = new Drawable[]
Name = @"Labels",
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, vertical_spacing),
Children = new Drawable[]
{
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsRankedScore),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsHitAccuracy),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsPlayCount),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsTotalScore),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsTotalHits),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsHitsPerPlay),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsMaximumCombo),
new ExtendedDetailsEntryLabel(UsersStrings.ShowStatsReplaysWatchedByOthers),
}
},
new FillFlowContainer
{
rankedScore = new OsuSpriteText { Font = font },
hitAccuracy = new OsuSpriteText { Font = font },
playCount = new OsuSpriteText { Font = font },
totalScore = new OsuSpriteText { Font = font },
totalHits = new OsuSpriteText { Font = font },
hitsPerPlay = new OsuSpriteText { Font = font },
maximumCombo = new OsuSpriteText { Font = font },
replaysWatched = new OsuSpriteText { Font = font },
}
},
Name = @"Values",
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, vertical_spacing),
Children = new Drawable[]
{
rankedScore = new ExtendedDetailsEntryValue(),
hitAccuracy = new ExtendedDetailsEntryValue(),
playCount = new ExtendedDetailsEntryValue(),
totalScore = new ExtendedDetailsEntryValue(),
totalHits = new ExtendedDetailsEntryValue(),
hitsPerPlay = new ExtendedDetailsEntryValue(),
maximumCombo = new ExtendedDetailsEntryValue(),
replaysWatched = new ExtendedDetailsEntryValue(),
}
},
}
}
};
}
Expand Down Expand Up @@ -115,5 +128,34 @@ private void updateStatistics(UserStatistics? statistics)
maximumCombo.Text = statistics.MaxCombo.ToLocalisableString(@"N0");
replaysWatched.Text = statistics.ReplaysWatched.ToLocalisableString(@"N0");
}

public partial class ExtendedDetailsEntryLabel : OsuSpriteText
{
public ExtendedDetailsEntryLabel(LocalisableString text)
{
Font = OsuFont.Default.With(size: 12);
Text = text;
}

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Colour = colourProvider.Content1;
}
}

public partial class ExtendedDetailsEntryValue : OsuSpriteText
{
public ExtendedDetailsEntryValue()
{
Font = OsuFont.Default.With(size: 12, weight: FontWeight.Bold);
}

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Colour = colourProvider.Content2;
}
}
Comment on lines +131 to +147

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved these elements into separate classes so as not to duplicate styles each time

}
}
Loading