2022-07-22 19:17:27 +00: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-07-22 20:11:45 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2022-07-22 19:17:27 +00:00
|
|
|
using osu.Framework.Allocation;
|
2022-07-22 19:42:42 +00:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions;
|
2022-07-22 19:17:27 +00:00
|
|
|
using osu.Framework.Graphics;
|
2022-07-22 19:42:42 +00:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2022-07-22 19:17:27 +00:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-07-22 20:11:45 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2022-07-22 19:17:27 +00:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2022-07-22 19:42:42 +00:00
|
|
|
public partial class AddPresetButton : ShearedToggleButton, IHasPopover
|
2022-07-22 19:17:27 +00:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; } = null!;
|
|
|
|
|
2022-07-22 20:11:45 +00:00
|
|
|
[Resolved]
|
|
|
|
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
|
|
|
|
|
2022-07-22 19:17:27 +00:00
|
|
|
public AddPresetButton()
|
|
|
|
: base(1)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = ModSelectPanel.HEIGHT;
|
|
|
|
|
|
|
|
// shear will be applied at a higher level in `ModPresetColumn`.
|
|
|
|
Content.Shear = Vector2.Zero;
|
|
|
|
Padding = new MarginPadding();
|
|
|
|
|
|
|
|
Text = "+";
|
|
|
|
TextSize = 30;
|
|
|
|
}
|
|
|
|
|
2022-07-22 20:11:45 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-08-03 19:23:31 +00:00
|
|
|
selectedMods.BindValueChanged(mods => Enabled.Value = mods.NewValue.Any(), true);
|
|
|
|
Enabled.BindValueChanged(enabled =>
|
2022-07-22 20:11:45 +00:00
|
|
|
{
|
2022-08-03 19:23:31 +00:00
|
|
|
if (!enabled.NewValue)
|
2022-07-22 20:11:45 +00:00
|
|
|
Active.Value = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-22 19:17:27 +00:00
|
|
|
protected override void UpdateActiveState()
|
|
|
|
{
|
|
|
|
DarkerColour = Active.Value ? colours.Orange1 : ColourProvider.Background3;
|
|
|
|
LighterColour = Active.Value ? colours.Orange0 : ColourProvider.Background1;
|
|
|
|
TextColour = Active.Value ? ColourProvider.Background6 : ColourProvider.Content1;
|
2022-07-22 19:42:42 +00:00
|
|
|
|
|
|
|
if (Active.Value)
|
|
|
|
this.ShowPopover();
|
|
|
|
else
|
|
|
|
this.HidePopover();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Popover GetPopover() => new AddPresetPopover(this);
|
2022-07-22 19:17:27 +00:00
|
|
|
}
|
|
|
|
}
|