mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 14:02:55 +08:00
Seperate UpdateableRank from DrawableRank and use it
This commit is contained in:
parent
0c299d651f
commit
794ba17a2f
@ -12,48 +12,46 @@ using System;
|
|||||||
|
|
||||||
namespace osu.Game.Online.Leaderboards
|
namespace osu.Game.Online.Leaderboards
|
||||||
{
|
{
|
||||||
public class DrawableRank : ModelBackedDrawable<ScoreRank>
|
public class UpdateableRank : ModelBackedDrawable<ScoreRank>
|
||||||
{
|
{
|
||||||
private TextureStore textures;
|
|
||||||
|
|
||||||
public ScoreRank Rank
|
public ScoreRank Rank
|
||||||
{
|
{
|
||||||
get => Model;
|
get => Model;
|
||||||
set => Model = value;
|
set => Model = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UpdateableRank(ScoreRank rank) => Rank = rank;
|
||||||
|
|
||||||
|
protected override Drawable CreateDrawable(ScoreRank rank) => new DrawableRank(rank)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DrawableRank : Sprite
|
||||||
|
{
|
||||||
private ScoreRank rank;
|
private ScoreRank rank;
|
||||||
|
|
||||||
public DrawableRank(ScoreRank rank)
|
public DrawableRank(ScoreRank rank) => this.rank = rank;
|
||||||
{
|
|
||||||
this.rank = rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(TextureStore ts)
|
private void load(TextureStore ts)
|
||||||
{
|
{
|
||||||
textures = ts ?? throw new ArgumentNullException(nameof(ts));
|
if (ts == null)
|
||||||
Rank = rank;
|
throw new ArgumentNullException(nameof(ts));
|
||||||
}
|
|
||||||
|
|
||||||
protected override Drawable CreateDrawable(ScoreRank rank)
|
Texture = ts.Get($@"Grades/{getTextureName()}");
|
||||||
{
|
|
||||||
return new Sprite
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
Texture = textures.Get($"Grades/{getTextureName()}"),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getTextureName()
|
private string getTextureName()
|
||||||
{
|
{
|
||||||
switch (Rank)
|
switch (rank)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return Rank.GetDescription();
|
return rank.GetDescription();
|
||||||
|
|
||||||
case ScoreRank.SH:
|
case ScoreRank.SH:
|
||||||
return "SPlus";
|
return "SPlus";
|
||||||
|
@ -193,7 +193,7 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Size = new Vector2(40f, 20f),
|
Size = new Vector2(40f, 20f),
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
scoreRank = new DrawableRank(score.Rank)
|
scoreRank = new UpdateableRank(score.Rank)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -103,7 +103,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Text = $"#{index + 1}",
|
Text = $"#{index + 1}",
|
||||||
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
|
||||||
},
|
},
|
||||||
new DrawableRank(score.Rank)
|
new UpdateableRank(score.Rank)
|
||||||
{
|
{
|
||||||
Size = new Vector2(30, 20)
|
Size = new Vector2(30, 20)
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
public class TopScoreUserSection : CompositeDrawable
|
public class TopScoreUserSection : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly SpriteText rankText;
|
private readonly SpriteText rankText;
|
||||||
private readonly DrawableRank rank;
|
private readonly UpdateableRank rank;
|
||||||
private readonly UpdateableAvatar avatar;
|
private readonly UpdateableAvatar avatar;
|
||||||
private readonly LinkFlowContainer usernameText;
|
private readonly LinkFlowContainer usernameText;
|
||||||
private readonly SpriteText date;
|
private readonly SpriteText date;
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Text = "#1",
|
Text = "#1",
|
||||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
|
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
|
||||||
},
|
},
|
||||||
rank = new DrawableRank(ScoreRank.D)
|
rank = new UpdateableRank(ScoreRank.D)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -121,7 +121,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
usernameText.Clear();
|
usernameText.Clear();
|
||||||
usernameText.AddUserLink(value.User);
|
usernameText.AddUserLink(value.User);
|
||||||
|
|
||||||
rank.UpdateRank(value.Rank);
|
rank.Rank = value.Rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DrawableRank(rank)
|
new UpdateableRank(rank)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 30,
|
Height = 30,
|
||||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) });
|
modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateLeftVisual() => new DrawableRank(Score.Rank)
|
protected override Drawable CreateLeftVisual() => new UpdateableRank(Score.Rank)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 60,
|
Width = 60,
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
switch (activity.Type)
|
switch (activity.Type)
|
||||||
{
|
{
|
||||||
case RecentActivityType.Rank:
|
case RecentActivityType.Rank:
|
||||||
return new DrawableRank(activity.ScoreRank)
|
return new UpdateableRank(activity.ScoreRank)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 60,
|
Width = 60,
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Screens.Ranking.Pages
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = user_header_height,
|
Height = user_header_height,
|
||||||
},
|
},
|
||||||
new DrawableRank(Score.Rank)
|
new UpdateableRank(Score.Rank)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
|
Loading…
Reference in New Issue
Block a user