mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add a red tint on mods incompatible with the current selection
This commit is contained in:
@ -11,12 +11,16 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
@ -43,6 +47,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
// A selected index of -1 means not selected.
|
// A selected index of -1 means not selected.
|
||||||
private int selectedIndex = -1;
|
private int selectedIndex = -1;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<IReadOnlyList<Mod>> globalSelectedMods { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the selected mod index of this button.
|
/// Change the selected mod index of this button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -236,7 +243,28 @@ 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;
|
||||||
Colour = mod.HasImplementation ? Color4.White : Color4.Gray;
|
updateColour(mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Colour4 lightRed;
|
||||||
|
private Colour4 darkRed;
|
||||||
|
|
||||||
|
private void updateColour(Mod mod)
|
||||||
|
{
|
||||||
|
var baseColour = mod.HasImplementation ? Color4.White : Color4.Gray;
|
||||||
|
|
||||||
|
if (globalSelectedMods != null)
|
||||||
|
{
|
||||||
|
if (!globalSelectedMods.Value.Contains(mod))
|
||||||
|
{
|
||||||
|
if (!ModUtils.CheckCompatibleSet(globalSelectedMods.Value.Concat(new[] { mod })))
|
||||||
|
{
|
||||||
|
baseColour = mod.HasImplementation ? lightRed : darkRed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Colour = baseColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIcons()
|
private void createIcons()
|
||||||
@ -309,6 +337,14 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Mod = mod;
|
Mod = mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colour)
|
||||||
|
{
|
||||||
|
lightRed = colour.RedLight;
|
||||||
|
darkRed = colour.RedDark;
|
||||||
|
globalSelectedMods.BindValueChanged(_ => updateColour(SelectedMod ?? Mods.FirstOrDefault()), true);
|
||||||
|
}
|
||||||
|
|
||||||
public ITooltip GetCustomTooltip() => new ModButtonTooltip();
|
public ITooltip GetCustomTooltip() => new ModButtonTooltip();
|
||||||
|
|
||||||
public object TooltipContent => SelectedMod ?? Mods.FirstOrDefault();
|
public object TooltipContent => SelectedMod ?? Mods.FirstOrDefault();
|
||||||
|
@ -127,7 +127,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
var allMods = ruleset.Value.CreateInstance().GetAllMods();
|
var allMods = ruleset.Value.CreateInstance().GetAllMods();
|
||||||
|
|
||||||
incompatibleMods.Value = allMods.Where(m => incompatibleTypes.Any(t => t.IsInstanceOfType(m))).ToList();
|
incompatibleMods.Value = allMods.Where(m => m.GetType() != mod.GetType() && incompatibleTypes.Any(t => t.IsInstanceOfType(m))).ToList();
|
||||||
|
|
||||||
if (!incompatibleMods.Value.Any())
|
if (!incompatibleMods.Value.Any())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user