Skip to content

Commit

Permalink
为ban图添加图标
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwcgt committed Dec 28, 2024
1 parent 2cb04a3 commit a766a60
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public partial class TournamentBeatmapPanel : CompositeDrawable
private readonly Bindable<TournamentMatch?> currentMatch = new Bindable<TournamentMatch?>();

private Box flash = null!;
private PadLock padLock = null!;
private MapStatusIcon padLock = null!;
private MapStatusIcon banIcon = null!;
private readonly bool isMappool;

public TournamentBeatmapPanel(IBeatmapInfo? beatmap, string mod = "", bool isMappool = false)
Expand Down Expand Up @@ -113,7 +114,13 @@ private void load(LadderInfo ladder)
}
},
},
padLock = new PadLock
padLock = new MapStatusIcon(FontAwesome.Solid.ShieldAlt)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Alpha = 0f,
},
banIcon = new MapStatusIcon(FontAwesome.Solid.Ban)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Expand Down Expand Up @@ -203,6 +210,13 @@ private void updateState()
case ChoiceType.Ban:
Colour = Color4.Gray;
Alpha = 0.5f;

if (isMappool)
{
banIcon.Team = lastFound.Team;
banIcon.Show();
}

break;

case ChoiceType.Protected:
Expand All @@ -216,6 +230,11 @@ private void updateState()
Colour = Color4.White;
BorderThickness = 0;
Alpha = 1;

if (isMappool)
{
banIcon.Hide();
}
}

choice = lastFound;
Expand All @@ -231,18 +250,25 @@ protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> cr
=> new DelayedLoadWrapper(createContentFunc(), timeBeforeLoad);
}

private partial class PadLock : Container
private partial class MapStatusIcon : Container
{
private readonly IconUsage icon;

[Resolved]
private OsuColour osuColour { get; set; } = null!;

public TeamColour Team
{
set => lockIcon.Colour = value == TeamColour.Red ? osuColour.TeamColourRed : osuColour.TeamColourBlue;
set => spriteIcon.Colour = value == TeamColour.Red ? osuColour.TeamColourRed : osuColour.TeamColourBlue;
}

private Sprite background = null!;
private SpriteIcon lockIcon = null!;
private SpriteIcon spriteIcon = null!;

public MapStatusIcon(IconUsage icon)
{
this.icon = icon;
}

[BackgroundDependencyLoader]
private void load(TextureStore textures)
Expand All @@ -259,12 +285,12 @@ private void load(TextureStore textures)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
lockIcon = new SpriteIcon
spriteIcon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(22),
Icon = FontAwesome.Solid.ShieldAlt,
Icon = icon,
Shadow = true,
}
};
Expand Down

0 comments on commit a766a60

Please sign in to comment.