2021-01-25 20:22:37 +08:00
|
|
|
// 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.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Tournament.Models;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
|
|
|
public class TournamentModDisplay : CompositeDrawable
|
|
|
|
{
|
|
|
|
public string ModAcronym;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-01-25 21:57:35 +08:00
|
|
|
private void load(TextureStore textures, LadderInfo ladderInfo)
|
2021-01-25 20:22:37 +08:00
|
|
|
{
|
|
|
|
var texture = textures.Get($"mods/{ModAcronym}");
|
|
|
|
|
|
|
|
if (texture != null)
|
|
|
|
{
|
|
|
|
AddInternal(new Sprite
|
|
|
|
{
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Texture = texture
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-25 21:57:35 +08:00
|
|
|
var ruleset = rulesets.GetRuleset(ladderInfo.Ruleset.Value?.ID ?? 0);
|
|
|
|
var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == ModAcronym);
|
2021-01-25 21:21:53 +08:00
|
|
|
|
|
|
|
if (modIcon == null)
|
|
|
|
return;
|
2021-01-25 20:22:37 +08:00
|
|
|
|
2021-01-25 20:28:46 +08:00
|
|
|
AddInternal(new ModIcon(modIcon)
|
2021-01-25 20:22:37 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(0.5f)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|