2022-02-24 06:11:38 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-02-24 06:11:38 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Utils;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
|
|
|
public partial class IncompatibilityDisplayingModPanel : ModPanel, IHasCustomTooltip<Mod>
|
|
|
|
{
|
|
|
|
private readonly BindableBool incompatible = new BindableBool();
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
|
|
|
|
|
2022-05-12 00:37:31 +08:00
|
|
|
public IncompatibilityDisplayingModPanel(ModState modState)
|
|
|
|
: base(modState)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-24 06:11:38 +08:00
|
|
|
public IncompatibilityDisplayingModPanel(Mod mod)
|
|
|
|
: base(mod)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
selectedMods.BindValueChanged(_ => updateIncompatibility(), true);
|
|
|
|
incompatible.BindValueChanged(_ => Scheduler.AddOnce(UpdateState));
|
|
|
|
// base call will run `UpdateState()` first time and finish transforms.
|
|
|
|
base.LoadComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateIncompatibility()
|
|
|
|
{
|
2022-04-18 03:20:16 +08:00
|
|
|
incompatible.Value = selectedMods.Value.Count > 0
|
|
|
|
&& selectedMods.Value.All(selected => selected.GetType() != Mod.GetType())
|
|
|
|
&& !ModUtils.CheckCompatibleSet(selectedMods.Value.Append(Mod));
|
2022-02-24 06:11:38 +08:00
|
|
|
}
|
|
|
|
|
2022-06-24 13:48:43 +08:00
|
|
|
protected override Colour4 BackgroundColour => incompatible.Value ? ColourProvider.Background6 : base.BackgroundColour;
|
|
|
|
protected override Colour4 ForegroundColour => incompatible.Value ? ColourProvider.Background5 : base.ForegroundColour;
|
2022-04-21 04:59:37 +08:00
|
|
|
|
2022-02-24 06:11:38 +08:00
|
|
|
protected override void UpdateState()
|
|
|
|
{
|
|
|
|
base.UpdateState();
|
2022-04-21 04:59:37 +08:00
|
|
|
SwitchContainer.FadeColour(incompatible.Value ? Colour4.Gray : Colour4.White, TRANSITION_DURATION, Easing.OutQuint);
|
2022-02-24 06:11:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#region IHasCustomTooltip
|
|
|
|
|
|
|
|
public ITooltip<Mod> GetCustomTooltip() => new IncompatibilityDisplayingTooltip();
|
|
|
|
|
|
|
|
public Mod TooltipContent => Mod;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|