mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
update another scores design
This commit is contained in:
@ -5,6 +5,7 @@ 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.Graphics.Sprites;
|
||||
@ -16,62 +17,63 @@ using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
public class DrawableScore : Container
|
||||
{
|
||||
private const int fade_duration = 100;
|
||||
private const float side_margin = 20;
|
||||
private const float text_size = 14;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly Box hoveredBackground;
|
||||
private readonly SpriteText rank;
|
||||
private readonly SpriteText scoreText;
|
||||
private readonly SpriteText accuracy;
|
||||
private readonly SpriteText maxCombo;
|
||||
private readonly SpriteText hitGreat;
|
||||
private readonly SpriteText hitGood;
|
||||
private readonly SpriteText hitMeh;
|
||||
private readonly SpriteText hitMiss;
|
||||
private readonly SpriteText pp;
|
||||
|
||||
private readonly ClickableScoreUsername username;
|
||||
|
||||
private readonly APIScoreInfo score;
|
||||
private Color4 backgroundColor;
|
||||
|
||||
public DrawableScore(int index, APIScoreInfo score)
|
||||
{
|
||||
ScoreModsContainer modsContainer;
|
||||
FillFlowContainer modsContainer;
|
||||
|
||||
this.score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 30;
|
||||
Height = 25;
|
||||
CornerRadius = 3;
|
||||
Masking = true;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
hoveredBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
},
|
||||
new OsuSpriteText
|
||||
rank = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = $"#{index + 1}",
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
Margin = new MarginPadding { Left = side_margin }
|
||||
},
|
||||
new DrawableFlag(score.User.Country)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
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 = 100 }
|
||||
//},
|
||||
modsContainer = new ScoreModsContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.06f,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = 0.42f
|
||||
TextSize = text_size,
|
||||
X = ScoreTextLine.RANK_POSITION,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
new DrawableRank(score.Rank)
|
||||
{
|
||||
@ -79,64 +81,232 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(30, 20),
|
||||
FillMode = FillMode.Fit,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = 0.55f
|
||||
X = 45
|
||||
},
|
||||
new OsuSpriteText
|
||||
scoreText = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $@"{score.TotalScore:N0}",
|
||||
Font = @"Venera",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = 0.75f,
|
||||
FixedWidth = true,
|
||||
X = ScoreTextLine.SCORE_POSITION,
|
||||
Colour = Color4.Black,
|
||||
TextSize = text_size,
|
||||
},
|
||||
new OsuSpriteText
|
||||
accuracy = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $@"{score.Accuracy:P2}",
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = 0.85f
|
||||
X = ScoreTextLine.ACCURACY_POSITION,
|
||||
TextSize = text_size,
|
||||
},
|
||||
new OsuSpriteText
|
||||
new DrawableFlag(score.User.Country)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = $"{score.Statistics[HitResult.Great]}/{score.Statistics[HitResult.Good]}/{score.Statistics[HitResult.Meh]}",
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
Margin = new MarginPadding { Right = side_margin }
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(20, 13),
|
||||
X = 230,
|
||||
},
|
||||
username = new ClickableScoreUsername
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
User = score.User,
|
||||
X = ScoreTextLine.PLAYER_POSITION,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
maxCombo = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $@"{score.MaxCombo:N0}x",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.MAX_COMBO_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
hitGreat = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $"{score.Statistics[HitResult.Great]}",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.HIT_GREAT_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
hitGood = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $"{score.Statistics[HitResult.Good]}",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.HIT_GOOD_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
hitMeh = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $"{score.Statistics[HitResult.Meh]}",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.HIT_MEH_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
hitMiss = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $"{score.Statistics[HitResult.Miss]}",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.HIT_MISS_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
pp = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = $@"{score.PP:N0}",
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.PP_POSITION,
|
||||
TextSize = text_size,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
modsContainer = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = ScoreTextLine.MODS_POSITION,
|
||||
},
|
||||
};
|
||||
|
||||
if (index == 0)
|
||||
scoreText.Font = @"Exo2.0-Bold";
|
||||
|
||||
accuracy.Colour = (score.Accuracy == 1) ? Color4.Green : Color4.Black;
|
||||
|
||||
hitGreat.Colour = (score.Statistics[HitResult.Great] == 0) ? Color4.Gray : Color4.Black;
|
||||
hitGood.Colour = (score.Statistics[HitResult.Good] == 0) ? Color4.Gray : Color4.Black;
|
||||
hitMeh.Colour = (score.Statistics[HitResult.Meh] == 0) ? Color4.Gray : Color4.Black;
|
||||
hitMiss.Colour = (score.Statistics[HitResult.Miss] == 0) ? Color4.Gray : Color4.Black;
|
||||
|
||||
background.Colour = backgroundColor = (index % 2 == 0) ? Color4.WhiteSmoke : Color4.White;
|
||||
|
||||
|
||||
foreach (Mod mod in score.Mods)
|
||||
modsContainer.Add(new ModIcon(mod)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.35f),
|
||||
Scale = new Vector2(0.3f),
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.Gray4;
|
||||
hoveredBackground.Colour = colours.Gray4;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
|
||||
rank.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
scoreText.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
accuracy.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
username.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
maxCombo.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
pp.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Great] != 0)
|
||||
hitGreat.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Good] != 0)
|
||||
hitGood.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Meh] != 0)
|
||||
hitMeh.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Miss] != 0)
|
||||
hitMiss.FadeColour(Color4.White, fade_duration, Easing.OutQuint);
|
||||
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
|
||||
rank.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
scoreText.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
username.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
accuracy.FadeColour((score.Accuracy == 1) ? Color4.Green : Color4.Black, fade_duration, Easing.OutQuint);
|
||||
maxCombo.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
pp.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Great] != 0)
|
||||
hitGreat.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Good] != 0)
|
||||
hitGood.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Meh] != 0)
|
||||
hitMeh.FadeColour(Color4.Black, fade_duration, Easing.OutQuint);
|
||||
|
||||
if (score.Statistics[HitResult.Miss] != 0)
|
||||
hitMiss.FadeColour(Color4.Black, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user