1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 18:02:55 +08:00
osu-lazer/osu.Game/Screens/Edit/Components/Menus/DifficultyMenuItem.cs
2022-06-24 14:50:11 +09:00

30 lines
1004 B
C#

// 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.
#nullable disable
using System;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit.Components.Menus
{
public class DifficultyMenuItem : StatefulMenuItem<bool>
{
public BeatmapInfo BeatmapInfo { get; }
public DifficultyMenuItem(BeatmapInfo beatmapInfo, bool selected, Action<BeatmapInfo> difficultyChangeFunc)
: base(string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? "(unnamed)" : beatmapInfo.DifficultyName, null)
{
BeatmapInfo = beatmapInfo;
State.Value = selected;
if (!selected)
Action.Value = () => difficultyChangeFunc.Invoke(beatmapInfo);
}
public override IconUsage? GetIconForState(bool state) => state ? FontAwesome.Solid.Check : null;
}
}