mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Display an icon to signify incompatibility instead of a red tint
This commit is contained in:
parent
3795030ebb
commit
6e3d05c7ce
@ -33,6 +33,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private ModIcon backgroundIcon;
|
private ModIcon backgroundIcon;
|
||||||
private readonly SpriteText text;
|
private readonly SpriteText text;
|
||||||
private readonly Container<ModIcon> iconsContainer;
|
private readonly Container<ModIcon> iconsContainer;
|
||||||
|
private readonly SpriteIcon incompatibleIcon;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when the selection changes.
|
/// Fired when the selection changes.
|
||||||
@ -243,28 +244,25 @@ namespace osu.Game.Overlays.Mods
|
|||||||
backgroundIcon.Mod = foregroundIcon.Mod;
|
backgroundIcon.Mod = foregroundIcon.Mod;
|
||||||
foregroundIcon.Mod = mod;
|
foregroundIcon.Mod = mod;
|
||||||
text.Text = mod.Name;
|
text.Text = mod.Name;
|
||||||
updateColour(mod);
|
Colour = mod.HasImplementation ? Color4.White : Color4.Gray;
|
||||||
|
updateCompatibility(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Colour4 lightRed;
|
private void updateCompatibility(Mod mod)
|
||||||
private Colour4 darkRed;
|
|
||||||
|
|
||||||
private void updateColour(Mod mod)
|
|
||||||
{
|
{
|
||||||
var baseColour = mod.HasImplementation ? Color4.White : Color4.Gray;
|
|
||||||
|
|
||||||
if (globalSelectedMods != null)
|
if (globalSelectedMods != null)
|
||||||
{
|
{
|
||||||
if (!globalSelectedMods.Value.Contains(mod))
|
if (!globalSelectedMods.Value.Contains(mod))
|
||||||
{
|
{
|
||||||
if (!ModUtils.CheckCompatibleSet(globalSelectedMods.Value.Concat(new[] { mod })))
|
if (!ModUtils.CheckCompatibleSet(globalSelectedMods.Value.Concat(new[] { mod })))
|
||||||
{
|
{
|
||||||
baseColour = mod.HasImplementation ? lightRed : darkRed;
|
incompatibleIcon.FadeIn();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Colour = baseColour;
|
incompatibleIcon.FadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIcons()
|
private void createIcons()
|
||||||
@ -312,11 +310,24 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
scaleContainer = new Container
|
scaleContainer = new Container
|
||||||
{
|
{
|
||||||
Child = iconsContainer = new Container<ModIcon>
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
iconsContainer = new Container<ModIcon>
|
||||||
Origin = Anchor.Centre,
|
{
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
},
|
||||||
|
incompatibleIcon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Icon = FontAwesome.Solid.Ban,
|
||||||
|
Colour = Color4.Red,
|
||||||
|
Size = new Vector2(30),
|
||||||
|
Shadow = true,
|
||||||
|
Alpha = 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -338,11 +349,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour)
|
private void load()
|
||||||
{
|
{
|
||||||
lightRed = colour.RedLight;
|
globalSelectedMods.BindValueChanged(_ => updateCompatibility(SelectedMod ?? Mods.FirstOrDefault()), true);
|
||||||
darkRed = colour.RedDark;
|
|
||||||
globalSelectedMods.BindValueChanged(_ => updateColour(SelectedMod ?? Mods.FirstOrDefault()), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITooltip GetCustomTooltip() => new ModButtonTooltip();
|
public ITooltip GetCustomTooltip() => new ModButtonTooltip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user