2022-02-24 06:11:12 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2022-07-23 01:14:39 +08:00
|
|
|
public class ModPanel : ModSelectPanel
|
2022-02-24 06:11:12 +08:00
|
|
|
{
|
2022-05-12 00:29:14 +08:00
|
|
|
public Mod Mod => modState.Mod;
|
2022-07-22 03:56:23 +08:00
|
|
|
public override BindableBool Active => modState.Active;
|
2022-05-12 00:29:14 +08:00
|
|
|
public BindableBool Filtered => modState.Filtered;
|
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
protected override float IdleSwitchWidth => 54;
|
|
|
|
protected override float ExpandedSwitchWidth => 70;
|
2022-02-24 06:11:12 +08:00
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
private readonly ModState modState;
|
2022-02-24 06:11:12 +08:00
|
|
|
|
2022-05-12 00:37:31 +08:00
|
|
|
public ModPanel(ModState modState)
|
2022-02-24 06:11:12 +08:00
|
|
|
{
|
2022-05-12 00:37:31 +08:00
|
|
|
this.modState = modState;
|
2022-02-24 06:11:12 +08:00
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
Title = Mod.Name;
|
|
|
|
Description = Mod.Description;
|
2022-02-24 06:11:12 +08:00
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
SwitchContainer.Child = new ModSwitchSmall(Mod)
|
2022-02-24 06:11:12 +08:00
|
|
|
{
|
2022-07-22 03:56:23 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Active = { BindTarget = Active },
|
|
|
|
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
|
|
|
Scale = new Vector2(HEIGHT / ModSwitchSmall.DEFAULT_SIZE)
|
2022-02-24 06:11:12 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-05-12 00:37:31 +08:00
|
|
|
public ModPanel(Mod mod)
|
|
|
|
: this(new ModState(mod))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
2022-02-24 06:11:12 +08:00
|
|
|
{
|
2022-07-22 03:56:23 +08:00
|
|
|
AccentColour = colours.ForModType(Mod.Type);
|
2022-02-24 06:11:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2022-05-07 22:35:34 +08:00
|
|
|
|
2022-07-22 03:56:23 +08:00
|
|
|
Filtered.BindValueChanged(_ => updateFilterState(), true);
|
2022-02-24 06:11:12 +08:00
|
|
|
}
|
2022-02-20 20:40:52 +08:00
|
|
|
|
2022-08-17 04:41:32 +08:00
|
|
|
protected override void Select()
|
2022-08-16 01:40:05 +08:00
|
|
|
{
|
2022-08-17 04:42:30 +08:00
|
|
|
modState.PendingConfiguration = Mod.RequiresConfiguration;
|
2022-08-17 04:41:32 +08:00
|
|
|
Active.Value = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Deselect()
|
|
|
|
{
|
2022-08-17 04:42:30 +08:00
|
|
|
modState.PendingConfiguration = false;
|
2022-08-17 04:41:32 +08:00
|
|
|
Active.Value = false;
|
2022-08-16 01:40:05 +08:00
|
|
|
}
|
|
|
|
|
2022-02-20 20:40:52 +08:00
|
|
|
#region Filtering support
|
|
|
|
|
|
|
|
private void updateFilterState()
|
|
|
|
{
|
|
|
|
this.FadeTo(Filtered.Value ? 0 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2022-02-24 06:11:12 +08:00
|
|
|
}
|
|
|
|
}
|