mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 13:33:52 +08:00
Split and rename TournamentModDisplay component
This commit is contained in:
parent
c6d46129ad
commit
f89eb7d75d
@ -9,14 +9,11 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -25,7 +22,7 @@ namespace osu.Game.Tournament.Components
|
||||
public class TournamentBeatmapPanel : CompositeDrawable
|
||||
{
|
||||
public readonly BeatmapInfo Beatmap;
|
||||
private readonly string mods;
|
||||
private readonly string mod;
|
||||
|
||||
private const float horizontal_padding = 10;
|
||||
private const float vertical_padding = 10;
|
||||
@ -40,7 +37,7 @@ namespace osu.Game.Tournament.Components
|
||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
Beatmap = beatmap;
|
||||
this.mods = mods;
|
||||
this.mod = mods;
|
||||
Width = 400;
|
||||
Height = HEIGHT;
|
||||
}
|
||||
@ -124,13 +121,16 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(mods))
|
||||
if (!string.IsNullOrEmpty(mod))
|
||||
{
|
||||
AddInternal(new ModSprite
|
||||
AddInternal(new TournamentModDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Mod = mods
|
||||
Margin = new MarginPadding(10),
|
||||
Width = 60,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
ModAcronym = mod
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -184,53 +184,5 @@ namespace osu.Game.Tournament.Components
|
||||
Alpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private class ModSprite : Container
|
||||
{
|
||||
public string Mod;
|
||||
|
||||
[Resolved]
|
||||
private LadderInfo ladderInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
public ModSprite()
|
||||
{
|
||||
Margin = new MarginPadding(10);
|
||||
Width = 60;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
var texture = textures.Get($"mods/{Mod}");
|
||||
|
||||
if (texture != null)
|
||||
{
|
||||
Child = new Sprite
|
||||
{
|
||||
FillMode = FillMode.Fit,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Texture = texture
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
Child = new ModDisplay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current =
|
||||
{
|
||||
Value = rulesets.GetRuleset(ladderInfo.Ruleset.Value.ID ?? 0).CreateInstance().GetAllMods().Where(mod => mod.Acronym == Mod).ToArray()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
osu.Game.Tournament/Components/TournamentModDisplay.cs
Normal file
56
osu.Game.Tournament/Components/TournamentModDisplay.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// 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 LadderInfo ladderInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
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
|
||||
{
|
||||
var mod = rulesets.GetRuleset(ladderInfo.Ruleset.Value.ID ?? 0).CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == ModAcronym);
|
||||
|
||||
AddInternal(new ModIcon(mod)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(0.5f)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user