move value set to constructor and make private readonly

This commit is contained in:
Shivam 2021-01-25 15:47:31 +01:00
parent 331a7d0590
commit b036f0165a
2 changed files with 9 additions and 5 deletions

View File

@ -123,14 +123,13 @@ private void load(LadderInfo ladder, TextureStore textures)
if (!string.IsNullOrEmpty(mod))
{
AddInternal(new TournamentModDisplay
AddInternal(new TournamentModDisplay(mod)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding(10),
Width = 60,
RelativeSizeAxes = Axes.Y,
ModAcronym = mod
});
}
}

View File

@ -16,15 +16,20 @@ namespace osu.Game.Tournament.Components
{
public class TournamentModDisplay : CompositeDrawable
{
public string ModAcronym;
private readonly string modAcronym;
[Resolved]
private RulesetStore rulesets { get; set; }
public TournamentModDisplay(string mod)
{
modAcronym = mod;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures, LadderInfo ladderInfo)
{
var texture = textures.Get($"mods/{ModAcronym}");
var texture = textures.Get($"mods/{modAcronym}");
if (texture != null)
{
@ -40,7 +45,7 @@ private void load(TextureStore textures, LadderInfo ladderInfo)
else
{
var ruleset = rulesets.GetRuleset(ladderInfo.Ruleset.Value?.ID ?? 0);
var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == ModAcronym);
var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == modAcronym);
if (modIcon == null)
return;